What is port forwarding in a computer network, and how to enable it on a network router?
Have you ever considered exposing a service to the outer world running over an internal LAN computer? It can be a web service or any other. One option is configuring a new public IP on the machine and letting the cable plugin connect to the ISP. It looks tricky as it needs to get a new public IP. What if there are many such services required?
Port forwarding in computer networking enables access to a service from anywhere that runs on an internal machine. For example, if you have a live website on a LAN machine with an internal IP (e.g., 192.168.1.4). Now, this website needs to access via the Internet.
Once you enable port forwarding on the LAN router, the internal website will be accessible from any corner of the globe.
The port forwarding is not limited to the internal LAN only. It could be any other IP.
How does port forwarding work?
The user needs to use the public IP address of the router with an optional port number (if other than the default port 80). Internet routes request to the public router. Router checks if any port forwarding is configured for a received destination port number. If not, the router may drop or handle the request.
Once a port forwarding entry is found, the router replaces the destination IP address with the new address (e.g., LAN IP ) and forwards it to the local machine. In a message from the local device to the client, the router sets the public IP in the source address.
The user feels that the service is running on public IP. Many such services can be on the same local machine with different port numbers.
How to configure port forwarding?
Port forwarding is a concept in networking. How to configure it depends on the brand of router you are using. Here are a few examples. You can configure it even with Linux if it works as a gateway.