Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
I've got a program here, that should listen on a port, say port 2000.
Now, it is impossible to configure that program to bind to one IP out of many, that my machine has.
This program binds to every IP, but I don't want that, since I have different servers running on the same port, but on different IPs.
What I need, is an "external" way of controlling, to what IP that program may bind.
I doubt very much that what you what can be done. At the lower internal levels of TCP/IP communication, the address to which an server socket is bound is a deliberate parameter chosen by the programmer/designer. Once the program has been compiled, it is not generally possible to alter the object code.
--- rod.
By "external" I assume you mean an external connection being initiated to the port 2000 listening on the server.
You can control which IP answers simply by insuring that each of your NICs is on a specific network (separate VLANs) so that traffic between that external connection and your server can only find a route that way.
You can fine tune that by using iptables to specify which external IP can connect to which internal IP. iptables is the firewall software built into most Linux system. It can be used for far more than basic firewall.
We do something similar to systems where we allow ssh traffic into the server on our internal facing NIC but NOT on the externally NATed NIC that is visible to the internet.
By "external" I assume you mean an external connection being initiated to the port 2000 listening on the server.
Um, no, by "external" I meant a tool, or something like that, with which I could force a program to bind to a specific IP. The program, that uses the TCP/IP connection, can bind to an IP address itself, but I want to control that from outside the program.
Anyway, I like your suggestion, though. This would need us to restructure things but maybe this is just what I am looking for, thanks for that.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.