Port forwarding, or port mapping, allows remote servers and devices on the internet to access the devices that are within your private local-area network (LAN) and vice versa. Without port forwarding, only devices that are part of the internal network can access each other, and with port forwarding, anyone can.
Essentially, port forwarding maps an external “port” on your internet-facing IP address to a particular computer on your local private network. This allows you (or someone else) to access something on your computer from the internet.
How does port forwarding work?
Ports are how computers distinguish between multiple services listening on one computer.
Using ports lets a device run a myriad of different processes and services. Each service has its own port – for example, email servers usually use port 587 while websites use port 80.
In total, there are more than 65,000 different ports, but only about 1,000 are used regularly. The others can be assigned to the devices or applications of your choice, and this process is called port forwarding.
Types of port forwarding
There are several types of port forwarding, with each of them serving different purposes. Local and remote port forwarding uses the TCP port 22, or SSH Tunneling.
Local port forwarding. This type of port forwarding is used when you want to use your LAN device to get data from a destination that you don’t have access to, but a device in the middle, or an intermediate, has. This allows for data to be pulled from the remote destination to your local device.
Remote port forwarding. This type of port forwarding allows your device to be visible to other remote devices or on the internet. In this case, data is being pushed from your device to the remote destination server, and then back to the source port and to your device. With remote forwarding, anyone on the internet or remote device can get access to your device.
Dynamic port forwarding. Dynamic port forwarding is virtually an extension of the local port forwarding. The difference is that any program from your LAN device can use the SSH tunnel and access any remote destination port by using only one port on your side. Dynamic port forwarding works by creating a proxy of sorts.
Port forwarding used
Port forwarding might seem like it’s in the purview of IT professionals and programmers. While those kinds of people are certainly heavy users of port forwarding, it’s useful for a far wider range of the computer-using population.
Here are some of the most common uses for port forwarding:
Hosting game servers for multiplayer gaming accessible from outside your home network.
Running remote desktop protocols for accessing your computer remotely.
Permitting file transfers from your computer to the outside world, or external networks.
Running a publicly-accessible website from your home computer.
Hosting your own VPN server that allows you to access your home network from afar.