Port forwarding allows computers over the Internet to connect to a specific computer or service within a private network. It’s basically making your computer accessible over the Internet, even though you’re behind a router.
For example, let’s say a friend of yours at their home wants to remotely control your computer at your home using a service such as Remote Desktop. Now, Remote Desktop Connection is a service built into Microsoft Windows that enables you to connect to another computer running Microsoft Windows. Once you’re connected to the remote computer you can use that computers programs and files just as if you were sitting in front of it.
Your friend is ready to connect to your computer, so he starts up the Remote Desktop connection and sends the request to your public IP address with a specific port number. A port is a logical connection that is used by programs and services to exchange information. Ports uniquely identify these programs and services that are running on a computer.
In the case of Remote Desktop, it uses port 3389, so the request with that port number will make its way through the Internet to your router. Once it reaches your router, your router needs to know where to forward the request for port 3389. Without any port forwarding configured your friend will not be able to connect to your computer because your router does not know what to do with this request.
Port Forwarding Configuration
This is where port forwarding comes in. By setting up port forwarding we’re telling our router to send or forward any requests with specific port (3389 in our case) and send the request to specific computer. Usually this is done by to logging in to our routers configuration page by typing in the routers internal IP address using a web browser. If you’re not sure what your router internal private IP addresses is, you just open up a command prompt on a Windows computer and type in ‘ipconfig’ and press Enter. In the result, the ‘default gateway’ is the internal IP address of your router.
It’s also important to know what your computer’s IP address is, which can also be seen in the output of ‘ipconfig’ command (typically IPv4 Address). We’re going to be entering that IP address in the port forwarding configuration page.
Depending upon what router you’re using the configuration page will be different. Whatever type of router you’re using, you need to go to the port forwarding section to configure port forwarding. There you’ll typically enter a name for the application (remote desktop in our case). Then we have to forward the remote desktop connection port to the computer, so we would type in the remote desktop port number which happens to be 3389, and then enter the IP address of the computer that we want our friend to access. When we’re done, when our friend sends a request with port 3389, the router knows where to forward that request to.
Common ports
In a network, the router is contacted with an IP address along with a port number. The router will look at the port number and send or forward the request to the internal IP address that the port has been configured to. Ports are always associated with an IP address and they are identified by a unique number. Regardless if you see the port number or not, a port number is always associated with an IP address. This is because an IP address always has a purpose and it uses the port number to determine what the purpose is. It always has a purpose that’s determined by the port number because not only our ports associated with an IP address but they are also always associated with an application or process such as FTP, web pages, email and so on.
The port numbers range from 0 to 65535 but of the 65,000, there’s a few of these that are most common and that are used on a daily basis. For example, port 80 which is used for web pages There’s also ports 20 and port 21 which are used for File Transfer Protocol or FTP. Port 443 which is used for bringing up secure web pages. In fact there is a privileged category of ports that are called the well-known ports which ranges from port 0 to 1023.