Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Connecting to workstation behind NAT

Status
Not open for further replies.

ronofto

Programmer
May 14, 2010
4
US
I am developing a TCP/IP server side application that, when accepting a new client connection, must open (in a client role) an independent connection back to a service that is running at the client’s workstation and listening on a known port. If additional clients at that workstation connect to my server I want to detect that I’m already communicating with the service running there and not connect again.

If the client workstation is not behind NAT, then the client workstation’s ip address can be retrieved when the accept is done at my server and the server then opens a connection to the known port at that ip address. The client’s ip address can be placed in a memory table so if another application from the same workstation connects to the server it is a simple lookup to see that the independent connection back has already been done.

Is there a way to accomplish the same functionality when the client workstation is behind NAT? Now when the server accepts the new connection the ip address that it sees is the one exposed by NAT and not that of the actual client workstation. The sin-port that can be obtained provides a mapping (known to NAT of course) back to the specific client that sent the message in. But there doesn’t seem to be sufficient information for the server to open a connection to the well known port at the workstation behind NAT where the client that originated the message is running.

I understand there is inbound NAT mapping but that seems to target the need to open to a limited number of apps behind the NAT and not a service on every single machine. And even if inbound mapping were done it is not clear that my server would know who to try and connect with. And if I can achieve the desired functionality without inbound mapping, is it then possible to configure NAT to allow all inbound communication to the known port regardless of which machine behind the NAT that it is destined for?

Any help would be appreciated.
 
A bit confusing...tell me where the server is and where the client is. Are they in the same building? Going across the internet? If they are connecting across the internet, then is the server not being NATted?

/

tim@tim-laptop ~ $ sudo apt-get install windows
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Couldn't find package windows...Thank Goodness!
 
The server and all workstations are within a company environment and they may or may not be co-located in the same building. At satellite locations multiple workstations may be located behind a router. Or there may be a number of workstations connected to a terminal server.
 
Again, is the server NATted, or does it have a public (routable) ip address?

/

tim@tim-laptop ~ $ sudo apt-get install windows
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Couldn't find package windows...Thank Goodness!
 
Sorry --- the server has a public ip address
 
Interesting dilemma...static NAT allows the same port to be mapped to only one IP address. The only solution I can think of off top is to maybe somehow configure the service to be able to use a range of ports, and statically NAT (PAT) using each separate port. That way, the server can keep a record of the same IP but can differentiate between hosts by port number...

Now you're gonna make me think... :)

/

tim@tim-laptop ~ $ sudo apt-get install windows
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Couldn't find package windows...Thank Goodness!
 
If the client side application runs as a service you could write the application in such a way that it should check certain strings e.g specifics port(s) and if that port(s) is/are already in use the server side will know to terminate any new connection to the client.
 
Unfortunately, one pice of backgound information is that I have no control over the clients connecting to my server. My server is really just an intermediary and before I can pass messages on I have to do some orthagonal checks (which is why I have to communicate to the independent client, which I do control, running on the workstation)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top