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!
12 Answers
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.
In the above example, to forward to port 7777 on the internal host you would just change Local Port to 7777.
You have it correct. Your router will have a configuration page for port forwarding where you enter these values. You need the following information:
- Original port (as set by source): The port that will be used externally, from the internet to your router, in your example 10000.
- 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.
- 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.
- 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