General discussion


How to connect a NAT behind machine

By harishdixit ·
please tell me how a machine connected to internet will send Connect request to it's LAN client behind a NAT. Because first request will go to the LAN server. And this LAN client is not directly visible to us.

it returns "Socket is not connected" error code - WSAENOTCONN

situation is like:

------------- ------------------ --------- --------
|Machine A| --------- >> |internet(WAN)| ------------>> |Server|----- >|M/C B|
------------- ------------------- --------- --------


machine A is not in a LAN, it is connected to internet with static IP. while B is in a LAN, behind a Server . and this server having public IP Address. B is not directly accessible , we can access it only through server. my one application is running on B and can connect to A when a connection request is made. My another apllication is running on A.

A has a static IP, while machine B is not publicly visible outside world. but we know IP address of server,and of machine A and machine B. and also port no on B and A.

problem is that when i send a connect request to B from A, via Server
then connection is not established.

If we try to establish a connection from B to A then it succeded,
while from A to B it will not.

port forwarding is one solution.But my situation is that
there may be many machines on the LAN and many outside machines
can connect to these LAN machines. Means (m to n) relationship is there.
So in this case how port forwarding will work ?

each time in my connect() request my destination
machine address will be changed.

Is there any solution by which we can do port forwarding for
any destination machine.Means it should be independent
on any manual entry in NAT device.

I am using socket programming Winsock 2 API in VC++.


This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Comments

Collapse -

by AmberHaze In reply to How to connect a NAT behi ...

While not a detailed solution, I have a similar situation which I set up a while back.

In my case, the "intervening server" is Linux based so it was easy to create a "login" webpage which creates a temporary port forward in the nat table which in turn allows the appropriate connection.

I hope this gives you a germ of an idea for your situation

Related Discussions

Related Forums