Showing results for 
Search instead for 
Did you mean: 

How to establish a connection from virtual IP

Go to solution
T Jose

How to establish a connection from virtual IP



My server is having 1 physical Ip and multiple virtual IPs.

When I try to connect to another system using TCP it is always establishing connection with physical IP address.

How can I connect with virtual IP from my server?




Duncan Edmonstone
Honored Contributor

Re: How to establish a connection from virtual IP

I assume what you mean here is that when you initiate an _outbound_ connection from a system with a VIP on it, after you ahve made the connection, when you look on the remote system at the source of the connection it is showing up as the physical IP address, rather than the VIP?


The issue is that unless you specifically set routes that use the VIP in your routing table, the chances are that the program you are using will just default to whatvere the routing table is telling it... there may be programmatic ways around this depending on what you program you are using to connect to the remote system, but more likely you would have to fiddle with the routing table to acheive what you need. You might want to read the section in the Serviceguard manual entitled "Using a Relocatable Address as the Source Address for an Application that is Bound to INADDR_ANY" which describes a similar if not identical situation and should get you thining about this.


Occasional Visitor

Re: How to establish a connection from virtual IP

Duncan is absolutly correct in that the "system" will pick the source IP address for an outbound TCP connection (or when sending an outbound UDP packet). The algorithm used is actually quite complex and is based in very dynamic kernel tables. The bottom line is that the application MUST make a bind(2) system call to bind to a local IP address before calling connect(2) if there is a requirement to use a specific local IP address for the outbound connection. Of course that requires access to the source code so you may need to work with the application vendor.