When is port forwarding required?

I am looking for networks to use in the dual-player game that I am writing, and I still do not understand when the device must have a port redirected to communicate with the outside world.

From what I saw in other games, port forwarding is always required to host the server, but not required on the client. In addition, there are other situations, such as skype (which, in my opinion, ultimately the client to the client), where neither end should redirect the port.

So my question is, when sending over the Internet, when there are and there are no port forwardings, and what steps can I take as a developer so that my users do not worry about this? Thanks in advance!

+7
source share
3 answers

Port forwarding is necessary when a machine on the Internet needs to initiate a connection to a machine that is located behind a firewall or NAT router. If the connection is initiated by the machine behind the firewall, the firewall / router will automatically recognize the response traffic and send it to the machine that opened the connection.

But if the packet arrives at the external interface, and it is not part of such a connection, the router must know what to do with it. By default, he will reject it. But if forwarding is configured for the port, this indicates which internal machine to send it to.

In other words: you need port forwarding, if you want to start the server behind the NAT firewall / router, you do not need it if you just start the client.

+9
source

Port forwarding (occurs) when NAT , firewall, or some other device blocks communication on all or some of the ports.

To answer your question as an example, most commercial routers use NAT to allow multiple people to use the same IP address (as a view from the outside world) provided by Internet service providers. Most ISPs use NAT to allow multiple clients to use the same IP address (as seen from the outside world). For this to work, NAT changes the internal IP address and communication port number to an external IP address (only for the entire subnet network) and a new port number. By doing so, the / isp / ect router can determine which internal IP and port each external message belongs to.

At any time when one of the computers communicating over the Internet is behind NAT, port forwarding is required. I am sure that there are more situations than this, and the solution for each can be quite complicated. But this covers the vast majority.

+2
source

There is a reason why Skype is not required (not always) you need to manually configure port forwarding:

When you install Skype, a port above 1024 is selected randomly, since the port is for incoming connections. You can configure Skype to use a different port for incoming connections if you want, but if you do, you must open the alternate port manually .

If the port selected for incoming connections becomes unavailable, by default ports 80 and 443 will be used as alternatives . If another application (such as an Apache or IIS HTTP server) uses these ports, you can configure the application to use other ports , or you can configure Skype to not use these ports.

Port forwarding is required if you are hosting a server. You can use the same technique as Skype ... I'm not sure if there is another option ...

+1
source

All Articles