1820225 Members
3932 Online
109620 Solutions
New Discussion юеВ

Re: TCP and ports

 
David Reno
Advisor

TCP and ports

Is it possible to do the following configuration?
Two processes, A and B, are running on the same host. Multiple IP addresses are bound to the same physical ethernet port: 192.168.0.1 and 192.168.0.2 bound to lan0:1 and lan0:2. Both processes open and using the same TCP port number, 7000, on different IP addresses running on the same host. For example:
Process A using 192.168.0.1:7000 bound to lan0:1
Process B using 192.168.0.2:7000 bound to lan0:2

The reason for this configuration is to support a clustered application.

Thanks for the help,
David
9 REPLIES 9
Santosh Nair_1
Honored Contributor

Re: TCP and ports

From my understanding of sockets, the answer to your question would be yes. I believe this is how virtual hosts on many webservers works.

Hope this helps.

-Santosh
Life is what's happening while you're busy making other plans
Sanjay_6
Honored Contributor

Re: TCP and ports

Hi David,

My answer is also yes. I have 3 ip addresses bound to different lan ports and have SG on the system. No modification in the TCP port is required.

Hope this helps

thanks
Rainer von Bongartz
Honored Contributor

Re: TCP and ports

David,

Sure this will work, it is just the kind of functionality that multiple IP-Addresses were designed for.

Regards
Rainer
He's a real UNIX Man, sitting in his UNIX LAN making all his UNIX plans for nobody ...
John Waller
Esteemed Contributor

Re: TCP and ports

There is no problem with this setup as far as the server is concerned , but what is connecting to these sockets and do you specify an IP Address:port or just broadcast to a port. If you just broadcast to a port , then what will determine which process will answer the request.
Kevin Wright
Honored Contributor

Re: TCP and ports

the definition of a socket, or connection to allow communication is a pair of IP address AND ports..so this is fine..for example
a socket is this..

IPaddressHOSTA:PORT AND IPaddressHOSTB:PORT
Sridhar Bhaskarla
Honored Contributor

Re: TCP and ports

Very much possible. You don't have to do anything other than getting the interfaces up through service guard. System will take care of the rest as the underlying physical layer is the same for both the IP addresses.

-Sri
You may be disappointed if you fail, but you are doomed if you don't try
David Reno
Advisor

Re: TCP and ports

Thanks to everyone that answered my question. Those that got the most points gave the most technical answers, IMHO. No one gave a link to anything authoritative and exemplary, so I didn't assign anything over 7 points. Thank you all for your comments and experiences doing this.

For further background, client processes from other hosts would connect to the two unique IP addresses on the same port number.

From your answers, I feel comfortable that this is within the capabilities of TCP. If anyone wants to post a link to the appropriate section of a standards document or other authoritative documentation answering this exact question, I will assign 10 pts to them.

Again, I consider this answered, thanks.

David Reno
rick jones
Honored Contributor

Re: TCP and ports

authoritative documentation would probably be the relevant RFC's at www.ietf.org and mirror sites. something more readable would be the works of W. Richard Stevens. His Unix Network Programming would be a good place to start.

As far as the mechanics go, basically it is a matter of calling bind() with the sockaddr specifying both an IP address and a port number. Probably some details in the manpages for bind(), you might also peruse socket() and tcp.

There are no routing issues with multuiple aliases on the same NIC. However, if you decide to split the addresses across NICs, there can be some issues with having addresses in the same IP subnet on different NICs in the same system. You either have to start setting explicit static routes, or on 11.X you can set ip_strong_es_model to a value of one.
there is no rest for the wicked yet the virtuous have no pillows
Bill Thorsteinson
Honored Contributor

Re: TCP and ports

This is no problem as long as you bind to the address
as well as the port. Many programs bind to the port
on all addresses by default, so can't share ip addresses.

If the program must accepts an IP address to bind to
as well as the port number, then you can have different
programs on each address. Oracle, WebLogic, and
Apache are all programs that will bind a specific address.

Oracle binds all available addresses when you specify
a home address for the machine. I haven't noticed
any other program doing this.

If you bind a specific address for a port, you can then catch the remaining addresses by binding only the port.

Clustering may also require one or more multicast
addreses so the processes can share information.