Jump to content
  • Advertisement
Sign in to follow this  
jamesd128

Why port forwarding?

This topic is 2994 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

So I have a general understand of how NATs work and in why port forwarding is needed, what I don't understand is why it's needed in only certain cases. If I set up a TCP listening socket so someone can connect to me, I have to port forward the port that socket is listening on. Once someone connects to me, that socket spawns another socket for the actual communication to take place and assigns it a random port. My question is why does the listening socket's port need to be port forwarded, but the random port it creates for the communication socket does not need any port forwarding?

Share this post


Link to post
Share on other sites
Advertisement
On linux for example - some services (like Adobe Flash security mechanism) listens on 843 - ports below 1000.
To serve these requests but avoid running as root (or having suid bit set on your server binary) - generally it's security issue, forwarding (prerouting) can be used and everybody is happy.

Share this post


Link to post
Share on other sites
If you're sending outbound traffic on that port (before receiving inbound traffic), then the router can figure out that it needs to forward the incoming traffic on to you.

If it's the other way around (inbound happens first, and then outbound comes afterwards), then the router has no way to know who it should forward the inbound traffic to, so you've got to set up port forwarding in advance.


Applications can work around this issue and make manual port-forwarding unnecessary by using NAT-punch-through techniques (usually involving a 3rd party in the middle that both ends use to coordinate).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!