When is port forwarding necessary?

前端 未结 3 1145
滥情空心
滥情空心 2021-01-04 21:11

I\'ve been investigating networking for use in a two-player game I\'m writing, and I\'m still not clear on when a device must have a port forwarded in order to communicate w

相关标签:
3条回答
  • 2021-01-04 21:49

    There is reason why Skype don't (not always) need manual setting of port forwarding:

    When you install Skype, a port above 1024 is chosen at random as the port for incoming connections. You can configure Skype to use a different port for incoming connections if you wish, but if you do, you must open the alternative port manually.

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

    Port forwarding is must if you host a server. You can use same technique as Skype... I am not sure if there is any other option...

    0 讨论(0)
  • 2021-01-04 21:51

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

    To answer your question as an example, most commercial routers use NAT to allow multiple people to use the same IP(As view from the outside world) provided by ISPs. Most ISP's use NAT to allow multiple customers to use the same IP(As viewed from the outside world). To get this to work, the NAT changes the internal IP and the port number of a communication to THE(there is only one for the entire sub network) external IP and a new port number. By doing this, the router/isp/ect can tell which internal IP and port each external communication goes to.

    Anytime one of the computers communicating over the internet are behind a NAT, port forwarding is required. I'm sure there are way more situations than this, and the solution to each can be quite complicated. But this covers the vast majority.

    0 讨论(0)
  • 2021-01-04 22:09

    Port forwarding is needed when a machine on the Internet needs to initiate a connection to a machine that's behind a firewall or NAT router. If the connection is initiated by the machine behind the firewall, the firewall/router automatically recognizes the reply traffic and sends it to the machine that opened the connection.

    But if a packet arrives on the external interface, and it's not a part of such a connection, the router needs to know what to do with it. By default, it will reject it. But if forwarding is configured for the port, that tells it what internal machine to send it to.

    Put another way: you need port forwarding if you want to run a server behind the NAT firewall/router, you don't need it if you're just running a client.

    0 讨论(0)
提交回复
热议问题