0

Regarding the topic of port forwarding, I'm trying to allow external devices on the internet to communicate with a PC on at a specific port (e.g. port 10,000 on my PC).

However, it appears that port forwarding only allows you to specify the port on the router, on which if data is received, is then forwarded to the specified private IP device.

So how does this work? Let's say I configure my router to forward communications for private IP device 192.168.1.29 if the router received data at port 10,000. How would I forward this data to, say port 7777 on the private IP device? Is this possible?

I feel like I may not understand how port forwarding actually works.

I appreciate any help!

1
  • What is your router model? Most routers allow you to specify the local port. May 27, 2016 at 6:31

2 Answers 2

0

Without knowing what your router is, any answer is going to be generic and might not exactly represent how this would work on your router.

In general you would specify the public facing listening port, and then the private host and port. IE you could have a public listening port of 10000 for your public IP, forwarded to an internal host on a completely different port if you wanted.

Here is an example of how this would look on an ASUS router listening on port 10000 and forwarding it to an internal host on IP 10.0.0.10 and port 10000.

ASUS Port Forwarding

In the above example, to forward to port 7777 on the internal host you would just change Local Port to 7777.

0

You have it correct. Your router will have a configuration page for port forwarding where you enter these values. You need the following information:

  1. Original port (as set by source): The port that will be used externally, from the internet to your router, in your example 10000.
  2. Destination Port: The port to use on the LAN on which to forward the traffic. It can vary from the original port request by the source - this would be 7777 in your example.
  3. Destination IP Address: The IP address of the server on your LAN that is receiving the traffic. This either needs to be a fixed (non-dhcp) address or you must configure a reserved dhcp address for the PC acting as a server.
  4. Traffic Type: UDP, TCP or Both

It is trivial for a router to forward traffic on a different port than it receives it on. The port is a software construct and can be arbitrarily assigned (that isn't to say that it doesn't have an impact - it certainly can - but not in a physical sense). Both UDP (a connection less, datagram communication method) and TCP (a connection oriented protocol) embed the source and destination port numbers in the segment header of each packet. In effect, the router will replace the destination port address to the requested port.

Port forwarding is closely related to Network Address Translation (NAT), which is the process by which local private IP addresses are translated to the single public IP address that the router maintains. Because of how NAT works, in a normal NAT configuration it isn't possible for the router to know that unsolicited traffic from the internet is intended for a particular IP address on the LAN, instead the router tracks outgoing traffic for a given client / IP address, and (for most home routers) uses Port Address Translation (PAT) to keep track of what traffic belongs to which host on the LAN.

It does this by replacing the source address in the outgoing traffic with one designated for that local host. The external (internet) server being communicated with will embed that port as the destination port in the response, and so the router will be able to 'translate' that traffic to the correct local machine.

Port forwarding circumvents that to a degree - removing the requested port (the source port coming from the internet) from the pool of ports that can be used for PAT, and simply directs all traffic received on that port to the configured local IP address.

Just to be clear - this is an over broad generalization of fairly complicated stuff - this is by no means a comprehensive overview.

4
  • "Source port" is wrong. Even from the incoming side, it's still the UDP "destination" port that you're configuring – port-forwarding based on the actual source port is very rarely done. (Some routers do have an option for it though.) May 24, 2016 at 6:19
  • Standard port forwarding changes the destination port; that is correct. I was explaining the relationship between port forwarding, NAT, and PAT, and how they interract (and interfere) with each other. PAT is quite common, although most people think it's 'normal' NAT. Here is some info on it: web.cse.ohio-state.edu/~kannan/cse3461-5461/Cse3461.NAT-PAT.pdf
    – Argonauts
    May 24, 2016 at 6:53
  • To clarify that - the modification of the source ports is how many home routers implement a form of NAT, called PAT. This replacement is automated by the router's network stack, and is transparent to the machine on the LAN. It is a 'cheap' method to tag packets allowing the router to differentiate between packets intended for LAN PCs 'A', "B', 'C', etc. You'd need to have a nice enough router to run wireshark on it, or look at both sides (LAN and WAN) to see this in action.
    – Argonauts
    May 24, 2016 at 7:03
  • 1
    I'm not talking about transparent NAT. I'm talking about your "this is how port forwarding is configured" part at the very top. "The port that will be used externally, from the internet to your router" is not a source port in this context. May 24, 2016 at 8:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .