Whether you are hosting a trivial website or making a game available to other people, port forwarding is a great method to access software operating on your PC remotely. To understand port forwarding and its working, let’s begin with understanding a port.
What is a Port?
A port is essentially a simulated spot where network connections begin and end up. They are controlled by the OS of the computer and are software-based. Each port is linked with a particular service or process. Ports enable the computers to differentiate among various kinds of traffic with great ease. For instance, emails and webpages go to separate ports despite using the same internet to reach the computer.
What is a Port number?
Throughout all the network-linked devices, ports are consistent with each having a specific number. Many ports are assigned to specific protocols. All HTTP (Hypertext Transfer Protocol) messages, for instance, go to port 80 by default but can be customized to different port number if needed. IP addresses are responsible for delivering and receiving messages from certain devices whereas port numbers enable targeting of particular applications or services within those devices.
Ports enhance the efficiency of network connections
A huge variety of data move to and fro the computer using the same internet connection. Ports assist the computer to comprehend what to do with the received data. For better understanding, let’s take an example of Alice transferring an audio file to Bob with the help of FTP (File Transfer Protocol). Then Bob attached that file to an email and sent to Jerry with the help of SMTP (Simple Mail Transfer Protocol).
Bob receives the email using POP (Post Office Protocol). Bob now forwards this email to Natasha on her Gmail. Natasha receives the email with the help of IMAP (Internet Message Access Protocol) and read the email on the web page of Gmail.com with the help of HTTPS (Hypertext Transfer Protocol Secure).
In above example, the journey of audio file started with the help of FTP, SMTP, POP & IAMP protocol and ended with HTTPS, although, the file was just getting transferred from one computer to another.
What is Port Forwarding?
Port forwarding, also known as port mapping or tunneling is a process that enables computers or other private network services to connect over the internet with other private or public services or computers. It is an underlying process of impeding data traffic directed from the IP/port combination of the computer and redirecting it to another port and/or IP. The program operating on the host computer generally begins the redirection but it can also be done by an intermediate hardware component, like the firewall, router, or proxy server. Although a person delivering data to the server doesn’t know about what is going on, the data will still reach its final destination.
Port Forwarding explained
Mainly, port forwarding is utilized to optimize network speed, separate network traffic, and assign a network path to a particular network service or protocol. Port forwarding usually makes use of popular port numbers. Typically, it is executed at a gateway router residing at the boundary of a network to automate the procedure of recognizing and relocating network packets to the target port.
The process of port forwarding begins with packets that are generated when you direct a data request through the internet. A network router typically inspects the header of an IP packet and delivers it to a connected suitable interface which resultantly directs the data to the target information that is in the header.
However, in port forwarding, the diverting application or device reads the header of the packet, notes, & endpoint, and then rephrases the header data and delivers it to another computer, which is different from the proposed one. The secondary destined host can be a different port on the same IP, a different IP address utilizing the same port, or a different combo of two.
For instance, imagine a router gets a packet with a port number and IP address in the packet head. In case the router isn’t organized with port forwarding, first, it will recognize the port assigned to IP and then go towards transmitting the data. But when port forwarding is configured, it will internally move the packet to the target node.
How does Port Forwarding work?
Ports decide the way a computer differentiates between different services listening on a single computer. With the help of ports, a computer or a device can run a countless number of services and processes. Each service contains its unique port. For instance, websites use port 80 whereas email servers use port 587.
There are over 65,000 ports but only around 1000 of them are used frequently. The other ports can be allocated to the application or device of your choice, this procedure is called port forwarding. Network access translation (NAT) enables the entire internal devices to have the same external IP address.
To better understand the concept and working of port forwarding, let’s make use of a little allegory. You can consider ports just like doors to a home i.e. a computer is at 1234 Daisy Lane with almost 65,000 doors. If port 22 is listening, consider that door 22 is unlocked.
The problem with NAT is that it offers distinct addresses externally and internally. To keep going with the house example, consider that the outer world can only direct visits to Daisy Lane and not certain homes in the surrounding area. If a person asks for door 22, the gatekeeper i.e. signifying NAT on the router will not know which house to direct them.
It is where port forwarding comes into action. If you set some router settings, it can direct inbound links to the appropriate computer within the network.