What is Network Address Translation (NAT)?

Menu

To understand Network Address Translation (NAT), it is helpful first to understand a few concepts. The first of which is IP addresses, and more specifically the difference between private IPs and public IPs.

IP addresses

An IP address is a computer’s address on a network. As the Internet is just a really, really large network they are extremely important in helping sending information from one point to another. Just like when you send a letter, if you know the location of the other person you can successfully get it to them. On the Internet, if you know the IP address of the other device you can send information to it.

All devices connected to a network, whether they are computers, routers, servers or VoIP phones have an IP address.

There are three fundamentals to appreciate at this point:

All devices connected to a network have an IP address

These are public, which means that you know the IP address of a device you can send information to it

Every single IP address must be unique

Currently most devices on the Internet use something called IPv4 addresses, which looks like 123.456.789.0. The rest of this guide deals with IPv4 addresses.

IP exhaustion

The IP address of every single device connected to a network must be unique. Due to the makeup of IPv4 addresses (four blocks of numbers, each block between 0 and 255), there are 4,294,967,296 unique addresses. When the Internet was in its infancy, this was more than enough. However, as more and more devices connected to the Internet it was recognised that there was more demand than available addresses.

In order to cope with this excess demand, it was proposed to make a huge change to the architecture of the Internet, and that was to make some IP addresses private to allow them to be used more than once.

Private IPs

Private IP addresses are used within a network, and sit behind a public IP address. Any communication on the Internet is performed through the public IP address (it is often called a gateway). We use private IPs for devices that generally don’t need to be found on the Internet. For example, your PC only generally needs to retrieve information from the Internet. It’s extremely unlikely that someone will need to know the address of your PC. Therefore you don’t need to have a public IP address for it, a private one will do.

One way to think of it may be like a house. I might know that you live at 26 Random Street. That is your public address, and it’s easy to find. Inside your house there may be numerous rooms such as a kitchen, dining room and bedrooms. But from the outside I don’t know what they look like, the size of them etc.

And even though there is only one 26 Random Street in existence, there will be lots of properties with bedrooms and kitchens.

So private IP addresses differ to public IP addresses because they are not unique. They instantly free up a lot of address space on the Internet, as rather than having to give unique addresses to every connected device, we can allow numerous devices to “share” a public IP.

Certain IP addresses are reserved as ‘private’ IP addresses. If your device has one of the following IP addresses it means that it is sitting behind a public IP address and cannot be found directly on the Internet:

192.168.x.x

172.16.x.x to 172.32.x.x

10.x.x.x

Before we finally answer the question about what Network Address Translation is, we need to understand ports too.

What are ports?

We’ve already said that you can send information to another device that is connected to a network if you know it’s IP address.

But once the information gets there, how does the other device know what the information is for, and what program it should use for the data it has received?

For this we use port numbers. Therefore messages contain multiple bits of information – the IP address of the other device, and the specific port that should be used. Port numbers can range between 0 and 65535.

Some of these port numbers are reserved solely for one purpose. For example, your web browser will always use port 80. If you use an SMTP email client, that will ‘listen’ for emails on port 25. In essence, if some data comes in to your IP address on port 25 then you know it is email.

So what is Network Address Translation?

When devices communicate across the Internet they send messages to each other. These messages are similar to letters in that they have a ‘to’ address and a ‘from’ address. The ‘to’ address is the IP address of the device it wants to send the message to, and the ‘from’ address is the IP address (and port number) to send any return messages to.

One of the rules of private IP addresses is that they should never been seen on the Internet, because theoretically millions of devices could share that IP address, and routing to a private IP address would not work.

Therefore they need to be removed somehow when a device with a private IP is sending messages. And this is what Network Address Translation is – it is the process of rewriting the addresses on a message before it is transmitted across the Internet, or indeed rewriting it after it has been received.

But what is the private IP address rewritten to? Simple – it is rewritten as the public IP address of the device it is sitting behind.

In order to keep track of everything, when the private IP and port number is overwritten, a record is kept of where the message was going to. This is dynamic and the record is created when an outbound message is sent. Every now and then the record is deleted if it hasn't been used for some time.

This means that when a reply is received with the same details the incoming message can be rewritten and readdressed to the device that originally sent the message.

So that is Network Address Translation is. It is allowing numerous devices to share one IP address, and the necessary process of rewriting and translating the address (routing) information as messages are sent and received from the Internet.

NAT and VoIP calls

Network Address Translation can cause problems for VoIP calls, the most common of which is one way audio. This is because most VoIP calls consist of two parts:

Setting up the call

And then transmitting the audio

Unfortunately, the transmitting of audio will happen on different ports to the ones used to set up the call. So if we remind ourselves about how NAT works, when a message is sent out the router makes a record of the destination IP address and port.

When a reply is received from that exact location, it is compared against the record and the message can then be redirected to the original internal address.

This works fine for the first part of a VoIP call (setting up the call). However, when audio transmission begins it will use a different port. There is no record of a message to this IP address and specific port being used recently in the records, so the router doesn't know where to send the information. So it does the only thing it can do - ignore it.

This means that your VoIP call is set up with no problems, but you won't hear the other person as the audio information doesn't get through.

For more information on this, and how to resolve these problems, please read this article.