Port Forwarding

In computer networking, port forwarding or port mapping is an application of network address translation (NAT) that redirects a communication request from one address and port number combination to another while the packets are traversing a network gateway, such as a router or firewall. This technique is most commonly used to make services on a host residing on a protected or masqueraded (internal) network available to hosts on the opposite side of the gateway (external network), by remapping the destination IP address and port number of the communication to an internal host.

Port Forwarding
Port Forwarding

Why You Need to Forward Ports

So why exactly would you need to forward ports? While some applications take advantage of NAT to set their own ports and handle all the configuration for you, there are still plenty of applications that do not, and you’ll need to give your router a helping hand when it comes to connecting services and applications.

In the diagram below we’re starting with a simple premise. You’re on your laptop somewhere in the world, and you want to connect to your home network to access some files. If you simply plug your home IP address into whatever tool you’re using (an FTP client or remote desktop application, for example), and that tool doesn’t take advantage of those advanced router features we just mentioned, you’re out of luck. It won’t know where to send your request, and nothing will happen.

This, by the way, is a great security feature. If somebody connects to your home network and they aren’t connected to a valid port, you want the connection to get rejected. That’s the firewall element of your router doing its job: rejecting unwelcome requests. If the person knocking on your virtual door, however, is you, then the rejection isn’t so welcome and we need to do a little tweaking.

To solve that problem, you want to tell your router “hey: when I access you with this program, you’ll need to send it to this device at this port”. With those instructions in place, your router will make sure you can access the right computer and application on your home network.

How Port Forwarding Works?

Before we start you need to know that every computer on your local network (including your router) has it’s own unique IP address due to a technology called NAT (Network Address Translation). This technology is essential so your router can find and communicate with each wireless device on your network.

Every IP address is divided into ports (or lanes on a freeway). If you want to send data from one computer to another the first computer’s IP address uses a port and sends the information to a port on the second computer. When you want a computer to connect to the Internet, the request needs to go through your router. First, the router receives the request from the computer. Your router takes note of which device on your network asked for the information. Then the router turns around and begins accessing the Internet. When the router does this it uses an external IP address. Every simple Internet request coming from your local network will use the same external IP address. Once the request has been answered, the router intercepts the incoming “packet” or request and acts as border security. It then determines if it’s alright to continue. If it is it then sends it on the correct computer using that computer’s LAN or internal IP address.

Before you can begin to forward a port, the device you are forwarding ports to may need to have a Static IP Address. Some router’s require the computer you are forwarding ports to to have a non-changing IP address.