Just to let you know, we’re an affiliate for Amazon, Bluehost, CJ and Rakuten Marketing and some of the links below are affiliate links, meaning that, at no additional cost to you, I may earn a commission if you click through and make a purchase. Thank you if you use our links, we really appreciate it!
Port forwarding? What on earth is that I hear you say.
Well it's really not as complicated as it sounds.
Port forwarding basically enables incoming traffic from the Internet to reach the right application on the right device on your home network, be it a phone, tablet or your laptop. It has uses in online gaming, remote desktop applications, IP Cameras and more.
But before I get into the nitty gritty of Port forwarding, let's look at what ports and IP addresses are, as they're a fundamental part of port forwarding but and how the Internet works in general.
You probably know what an IP address is, but if you don't, they're simply a series of four digits, each one separated by a dot. So for example, 18.104.22.168.
Each device that you own has an IP address and they are used to uniquely identify devices on a network and on the wider Internet.
There are two types of IP addresses, public and private. The public ones are publicly accessible over the Internet, whilst private ones aren't and are used on internal networks. They tend to look like 192.168.x.x, or 10.0.x.x.
But when you sign up to an Internet Service Provider (ISP), they will assign you a single Public IP Address to your connection.
All computers and devices need a unique Public IP Address in order to send and receive data across the Internet.
It's helpful to think of your public IP address as like a street address and your internal private IP addresses like house numbers for that street address.
But you probably have more than one device in your house, and only a single public IP address given to you by your ISP. So when you Google something on your laptop, how does all the information from the Internet get back to your laptop and not you son or daughter's desktop if the public facing IP Address is the same for all your devices?
Well, let me explain.
Network Address Translation (NAT)
Behind the scenes, it's a NAT that solves this problem, and it's built directly into your home router.
A NAT or Network Address Translation acts like a traffic cop directing the flow of network traffic through your router enabling a single public IP Address to be shared across all your devices.
Thanks to Network Address Translation, we have a way of translating between public and private IP Addresses so that everyone in your household can use the internet at the same time; without fear that internet content will end up on the wrong device!
From the Internet's point of view, you are just a single computer with with a single IP Address.
OK so this is fine for generally browsing the internet, but what if you wanted to get access to your IP camera whilst on holiday or access some files stored on your laptop whilst your away?
Well this is where Port Forwarding comes into play.
But before we get onto Port Forwarding, let's look at Ports and learn what they are.
Image credit: Sean MacEntee/Flickr
What are Ports?
Every request you make across the internet includes a "port". The port is just a number and is used to work out where network traffic should be directed.
So when a data packet comes in from the Internet to a website's server, the operating system has a look at the port number contained in the data packet and works out where that packet is destined for. Each port corresponds to a different application, and in total there are 65,536 ports available to use in total.
Not all the ports are free to use however. The first 1,024 are fixed because they are part of a pre-defined standard that helps applications communicate across the global internet.
So for example, Port 80 is the standard port that web servers such as Apache or Nginx listen in on for unsecured HTTP traffic.
So for example, if you make a request to http://somewebsite.com the receiving server's software knows that Port 80 is used for serving http documents and so it listens on Port 80 and responds appropriately.
Other standard ports include Port 110, used for incoming POP3 email and FTP which listens on Port 20 and 21.
You can see a whole bunch of other well-known standard ports on Wikipedia.
Beyond Port 1024 is a free for all, and any software which runs on a server can be configured to listen on an arbitrary port such as 8080.
And finally we come to Port Forwarding.
Port forwarding is basically configuring a router so that a computer or network device connected to that router is accessible to other devices outside the local network.
In other words, when you enable port forwarding for a particular device, such as your IP camera, you are enabling others to connect to and access that device across the wider internet.
So let's take the example of the IP camera.
Here's the scenario: Your IP camera is connected to you router and your laptop is also connected to your router on your home Wi-Fi network.
The router will assign the IP camera and the computer an internal private IP Address. This enables the two devices to communicate with each other on the Local Area Network (your home Wi-Fi).
As mentioned above, these local IP addresses almost always start with 192.x.x.x or 10.x.x.x.
The modem which is often built into routers these days, are also assigned an IP address, but this is assigned by your ISP and as I mentioned above, this is the public IP Address.
The public IP Address enables communication between devices on your local network and the devices on the Internet.
Now by default, most routers have a Firewall installed so that no outside internet traffic can enter the local network, which is a great security feature.
Basically if somebody tries to connect to your home network and they aren't connected on a valid port, then their connection will be dropped.
However, if it is you trying to access your home network from afar, then your connection will be welcomed, but you need to do a bit of tweaking to enable this to happen.
When you setup port forwarding on you router, you are effectively punching a hole through the firewall. This allows internet traffic to seep through inside your local network, but only on a specific port that you have forwarded.
So for example, say our IP Camera is running on port 8081, you can setup port forwarding on the router and point port 8081 to the IP camera, then outside traffic will be allowed inside the network on that particular port. The router will then forward the traffic to the IP camera when it comes in over the internet. The image below illustrates this.
Port Forwarding use case - Multi-player Online Gaming
Online multi-player gaming is probably the most common reason for port forwarding.
Many games nowadays allow you to run a game server on your computer and will allow others to connect to it so that they can play along too.
Since it's not possible for you to connect to other people, they have to send connection requests to you.
Now if you don't configure your router correctly, it won't know what to do with the incoming requests or which device to send them to, so devices will fail to connect. Or rather the router will send back a network packet saying that it was unable to connect.
So to solve the problem, you have to set up a port forward on your router to the port that your local gaming server expects such as 81274 and you also have to specify the IP address of the computer that's actually running the server such as 192.168.5.3.
So from now on, the router will know to forward any external requests to 192.168.5.3 but only on port 81274 which is what your game server expects. Requests on ports other than 192.168.5.3 will be rejected by the router's firewall.
Most modern games do all of this manual work for you so it all happens automatically using Universal Plug and Play (UPnp).
UPnP is basically a protocol that was invented to enable applications to request ports and setup port forwarding rules.
UPnP works great most of the time and can save you time, but if you want to do things like access files on your computer or setup a remote desktop application, then you'll have to setup the forwarding manually.
Image credit: BagoGames/Flickr
So there's port forwarding for you. If you have an interesting use for port forwarding or may be you're doing something cool with your own web server, I'd love to know. Just let me know in the comments, I'd like to hear from you!