How do I make a TCP server work behind a router (NAT) without any redirection configuration needed

Chetane picture Chetane · Oct 2, 2009 · Viewed 8.5k times · Source

The scenario is the following. I have two machines A and B: A: Client (behind NAT) B: Server (behind NAT)

I want B to be able to listen on any given port, so that A can send packets to B through that specific TCP port and receive any response. If both machines are not behind a NAT it is pretty straight foward process. However how do I make it work so that it works even when B is behind a router, without him having to go change the router configuration enable some port forwarding etc...

For example, how do peer-to-peer programs like torrent clients work without the user having anything to configure?

Answer

Douglas Leeder picture Douglas Leeder · Oct 2, 2009

To answer the example of Peer to Peer programs, and in general: There is a technology called Universal Plug and Play which NAT routers can use to allow clients behind them to expose ports to the outside. That's what bittorrent clients can use so the other clients can directly connect to them.