facebook rss twitter

Port Forwarding

by Parm Mann on 20 October 2008, 00:00

Quick Link: HEXUS.net/qasa6

Add to My Vault: x

What is Port Forwarding?

Port forwarding is a technique you'll need to use to enable certain services if you're using a router. If you don't really care how it works, you can skip this section and just find out how to do it. First, let's take a look at how your average home router works.

To connect to the Internet, your modem not only needs to establish a connection with your ISP, it also needs an IP address. This is a series of numbers in the form 255.255.255.255. Every computer connected to the Internet has a unique IP address. With a router, you can connect more than one machine to the Internet. Most home users will only get one IP address, assigned by their ISP automatically. That means more than one computer is having to use the same IP, but as I've just said, each computer must have a unique IP. Stuck?

This is where network address translation (NAT) comes in. Your router has two network interfaces. One interface connects to the Internet and has the IP assigned by your ISP. The other interface connects with the computers on your local area network (LAN) and has an IP from a range reserved for private use. These private IPs can be used more than once on LANs across the world because they can't be used on the Internet. When a computer on the LAN needs to connect to something over the Internet, it uses the router as the gateway to the Internet. The router, using NAT, can remember which computer is requesting what, and forward all the requests to the Internet using the Internet-side IP. Any data returned is then passed back to the machine that requested it.

NAT works well for browsing the web, where the computer on the LAN is always the computer initiating the exchange of data. However, what if a computer on the Internet wants to initiate a connection. How does the router know which machine on the LAN to send the request to? The simple answer is it doesn't; it's impossible for it to tell. To get around this, we have to tell it what to do.

Let's imagine you're trying to play a game over the Internet that needs to receive a UDP connection from the other player. UDP connections aren't initiated, they're just sent in the hope that they'll get to their destination. So the computer over the Internet sends a UDP packet to your router, which then doesn't know where to send it. We are in luck, however, because if we know what port these UDP packets are sent on, we can tell the router where to forward them to. By now, a bell should be going off in your head. Ports... forward... port forwarding!