NAT Question

Hello and thanks in advance for any help you can provide. I am very new to this topic so please forgive my ignorance...

Here is my sistuation: Under current Windows (XP, etc), suppose I have two tcp/ip client processes running on the same machine from behind a NAT. Each process wants to use the same socket local address (IP/port) but connects to different remote address. Under Winsock 2, at least, it seems one can set a socket option to permit more than one socket to be bound to the same local address (setsocketoption with SO_REUSEADDR).

So my question is: will a NAT use the same port on its public interface for both of these sockets? Or to put it another way, will the two different remote processes "see" the same public IP/port?

Thanks.

Reply to
David White
Loading thread data ...

In article , David White wrote: : :Here is my sistuation: Under current Windows (XP, etc), suppose I have two :tcp/ip client processes running on the same machine from behind a NAT. Each :process wants to use the same socket local address (IP/port) but connects to :different remote address. Under Winsock 2, at least, it seems one can set a :socket option to permit more than one socket to be bound to the same local :address (setsocketoption with SO_REUSEADDR). : :So my question is: will a NAT use the same port on its public interface for :both of these sockets? Or to put it another way, will the two different remote :processes "see" the same public IP/port?

NAT should use the same local port for both connections. NAT operates on the principle of minimum change. Since the remote IP addresses are different, that is sufficient to uniquely identify the two connections, so no local port number change would be necessary. Now, if you had just a single public IP address and _two_ machines behind the NAT, and both of those machines were trying to talk from the same local port to the same remote address and port, then NAT would be forced to use a different local port number for the second connection.

Reply to
Robert Nichols

Most NAT implementations behave as you describe, but I've seen lazy ones that just use the 'next' local port number whether they need to or not.

Point is, if you write code that assumes NAT will not change the local port number, it *will* break occasionally.

Triffid

Reply to
Triffid

Cabling-Design.com Forums website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.