1

I understand the principle of: Port Forwarding; Network Address Translation etc.

Say I wanted to play multi player games. In this scenario; I would have to forward port 80 to my games server (computer 1).

How would this work if another user wanted to use the Internet on computer 2 whilst I was playing a multi player game or even whilst I was not playing a multi player game and the games sever is switched off? I have done some research and read questions like this: What is port forwarding and what is it used for?. However, I have not found an answer to my specific question. Do you have to setup the games server as a proxy server? i.e. specify the settings of computer B as the proxy server on computer A. Is that correct? I don't believe it is correct because the games server would sometimes be switched off.

1 Answer 1

1

First thing to note – each TCP and UDP socket has two ports: source and destination. Usually the source port is assigned randomly (or from a counter) and most software don't care about it. Your port forwarding rules also check only the destination port.

Second – port forwarding rules are only effective for a specific destination address (i.e. the router's own address), and most of the time only for packets coming in through a specific interface (i.e. the WAN port).


So you don't need to do anything specific, because:

  • If you connect to a website, the outgoing packets won't match forwarding rules for port 80 because they didn't arrive through the WAN interface and have a different destination address.

  • Incoming replies (from the website) also remain untouched because they have 80 as the source (remote) port, not as the destination (local) one, so they don't match the rules either.

Meanwhile, when someone wants to connect to your server, then the incoming packets will match the rules because they arrive through the WAN port, have the router's IP address as destination, and are sent to destination port 80 (which from the router's perspective is the local port).


For example, your router would keep a port-forwarding rule like this (paraphrased):

if (dst_ip = <ROUTER_IP> and dst_port = 80) then translate dst_ip to 192.168.1.42

An outgoing connection would create such packets:

out: LAN → router: IP(src=192.168.1.42, dst=<WEBSITE_IP>) / TCP(sport=34567, dport=80)
out: router → WAN: IP(src=<ROUTER_IP>,  dst=<WEBSITE_IP>) / TCP(sport=45678, dport=80)

in:  router ← WAN: IP(src=<WEBSITE_IP>, dst=<ROUTER_IP>)  / TCP(sport=80, dport=45678)
in:  LAN ← router: IP(src=<WEBSITE_IP>, dst=192.168.1.42) / TCP(sport=80, dport=34567)

Note how neither of those actually matches the port-forwarding rule.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.