NAT
NAT
Overview...................................................................................................................................................1
Part 1..........................................................................................................................................................1
RFC1918 and NAT Terms.......................................................................................................................2
RFC 1918...............................................................................................................................................3
NAT Terms:...........................................................................................................................................5
NAT Types.................................................................................................................................................7
Static NAT.............................................................................................................................................8
Dynamic NAT.....................................................................................................................................11
Source Address Theory....................................................................................................................11
NAT and PAT Theory........................................................................................................................14
Part 23.....................................................................................................................................................16
Cheat Sheet:...........................................................................................................................................18
Overview
Part 1
In the section we're going to discuss network address translation or NAT and port
address translation PAT.
We'll discuss why NAT is required?
Why do we use NAT in networks today?
We'll also discuss the difference between NAT and PAT and
we'll discuss the Cisco term overloading which implies NAT.
a lot of network engineers talk about NAT even though they actually mean PAT. So, we
need to understand the differences between those two terms and as always I'd like to
demonstrate how to set up NAT using the command line interface.
We'll look at different types of NAT including Static NAT, Dynamic NAT and PAT or
Overloading as Cisco call it.
#demonstration on PC #see video
so, a Network address translation, essentially translates a private IP address which is not
routable on the Internet to a publicly routable IP address. your public IP address is typically
allocated to you by your service provider, which in my case is British Telecom or BT here in
the UK.
In large networks, companies may register their own public IP addresses. Here are some
well-known examples, Hewlett Packard own 15.0.0.0/8 and 16.0.0.0/8, Apple own 17.0.0.0/8,
MIT 18.0.0.0/8 and so on.
So as an example, if you are working with HP or with an apple, you may not be using a
private IP address such as this (122.168.1.89). You may actually have a public IP address
allocated to your PC. These are globally routable public IP addresses that were registered by
some of the largest companies in the world. But IP addresses are running out. So, in most
small medium businesses today you'll be using a private IP address internally.
RFC 1918 was drafted in February 1996. So, in other words it's been around for a
long time. This discusses the address allocation for private internets. I'm not going to
bore you going through the entire document. But notice in section 3, they talk about
private address space.
The Internet assigned numbers authority or IANA has reserved the following three
blocks of IP address space for private internets
10.0.0.0 up to 10.255.255.255. In other words, a (10/8 prefix)
172.16.0.0 up to 1712.31.255.255. This is a (172.16/12 prefix) and then
We have 192.168.0.0 up to 192.168.255.255, this is a (192.168/16 prefix).
In my example here. I'm using a 192.168.1.89 address internally. What are you using
on your PC. More than likely if you're at home using one of these IP provision 4
addresses.
In companies as mentioned such as Apple or HP you may be using a public IP
address.
So, RFC 1918 was drafted to try and conserve IP addresses. The idea here is that
rather than allocating public IP addresses to every device in the Internet. Devices
within companies could be allocated these (above RFC 1918 addresses) addresses
and they could be NAT’ed or translated when they needed to access the Internet.
With port address translation or PAT. The idea is, is that you are overloading an IP
address. Hence the term that Cisco uses. We could have one public IP address used
by 500 internal devices.
These are RFC 1918 addresses are non-routable on the Internet. In other words,
Internet service providers will block or drop traffic going to or coming from these
address ranges.
Well that's assuming that they've configured the router correctly, but they should
have access lists blocking those addresses so that the non-routable on the Internet.
These are RFC 1918 addresses are used internally within organizations and hence we have
the term private addresses used within private networks and public addresses used on the
global or public internet.
Now Technically there's nothing stopping private IP addresses from being routed
across the Internet. The reason they non-routable is because ISP are blocking traffic
to or from those address ranges.
So, the issue is, if private IP addresses are non-routable, how do we get on to the
Internet. Well that's way network address translation or NAT comes in.
NAT allows us to translate a private IP address to a public IP address, your Internet
service provider or ISP will allocate you an IP address or a range of IP addresses
A router or another type of device will translate to your internal private IP addresses
to that globally routable public IP address.
Now the terminology that Cisco use, can be confusing and it's something that
people often struggle with.
Cisco use the terms Inside Local address, Inside Global address, Outside Local
address and Outside Global address.
NAT Terms:
Now the terms used to in network address translation can be very confusing. This is
probably one of the hardest things to understand with NAT.
NAT Types
For the CCNA course you need to know three types of NAT.
1. The first one is Static NAT.
2. Second one is Dynamic NAT and
3. Third one is PAT
Static NAT
Now Static NAT maps a private IP version 4 address to a public IP version 4 address.
This is a one to one mapping.
This is very useful when a device must be accessible from outside the network. For example,
you have a web server in your internal network. That needs to be accessible from devices on
the Internet.
So, this type of NAT is often used for servers that require a static IP address
Dynamic NAT
->Dynamic NAT maps a private IP version 4 address to a public IP version 4address from a
group of public provision for addresses or from a pool of addresses.
This could be used as an example where two companies merge, and they are using the
same IP address space.
So, you have two companies for example using IP addresses 10.1.1.0 and the devices in
those two companies need to talk to each other rather than renumbering you addresses,
you can use Dynamic NAT to allow those devices to talk to each other. It's not a very
efficient and should only be used when absolutely necessary.
PAT
->Now port address translational PAT maps multiple private IP addresses to a single public
IP address. So, in other words you are taking many IP addresses and mapping them to a
single public IP address.
Think of your network at home you may have multiple PCs, iPhones, iPads or other
devices that only to access the internet.
ISP however will typically only give you one IP address for your home network. So,
you may have three or four or maybe even more devices, let's say 10 IP devices that
are using one public IP address.
So, 10 devices or as many devices as you've got at home are using private IP
addresses and those addresses are then enacted to the public IP address on your
router.
This uses port numbers to differentiate between the different translations. Hence the term
port address translation.
PAT is also known as NAT overloading. We are overloading a single IP address with multiple
IP addresses. It's a type of dynamic NAT and is the most common type of NAT in use today
and you'll typically find it all over the place in businesses as well as your home network.
Part 7 demonstration of NAT are skipped for now. Static lab Demo.
Now with static NAT. There is a permanent mapping between the internal IP address
and a specified public IP address.
while in Dynamic NAT, individual private addresses are mapped to individual public
addresses in a pool of addresses.
->So as an example, if you had 10 IP addresses in your pool, the first host that sends traffic
will get to use the first IP address in the pool. The second host would use the second IP
address and so forth and so one. you're not explicitly mapping a public IP address to an
internal server IP address.
->So, when you set up a dynamic that you're going to set up a pool of addresses. you also
configure it inside and outside interfaces, but you don't create a static map to a single IP
address.
You create a pool of addresses that can be used by hosts internally.
Dynamic NAT
So, in Dynamic NAT once again. you are creating a pool of inside global addresses.
The reason why it's called dynamic rather than static is, the router dynamically allocates IP
addresses from the pool on a as needed basis.
The mapping will be removed once communication ends. So, there's no permanent
one to one mapping that's always there like you have with static NAT.
With dynamic NAT, the NAT translations are automatically created when they needed and
torn down or removed when not needed.
For those devices to access devices on the Internet their addresses need to be
translated or changed from an RFC 1918 address to a publicly routable address.
In this example the router has an IP address of 1.1.1.1 and we are going to not host
10.1.1.1 to an IP address of 1.1.1.2. So, in this example we not natting the PCs IP
address to the routers IP address. I'll show you that example in a moment.
In this example we are natting, one internal IP address or private IP address to a
dedicated public (1.1.1.2) IP address.
In this example we've also got a server on internet with an IP address of 2.2.2.2
So, the Router will populate to the NAT table as follows.
Inside a local address is 10.1.1.1
inside global is 1.1.1.2
outside local and outside global are set to 2.2.2.2
In this example we not natting the outside address, we are only natting the inside
address.
if you are sniffing this local area network connection between the PC and the
router using the wireshark and I'm going to demonstrate that in a moment.
what you would see is that, the source address of the packet is set to 10.1.1.1
That's the physical IP address of the host.
The destination address for Traffic is 2.2.2.2. In other words, the PC has
initiated a session to the server and if you capture traffic on the local network,
source addresses of the PC's actual IP address (10.1.1.1) and destination
address is the servers IP address (2.2.2.2).
However, when the traffic hits the router, the Router will look in the NAT table because it's
receiving traffic on an inside interface which you configure, and the traffic is destined to an
outside interface. So, you configure the Router with the inside and outside interfaces. And
because of that configuration the router looks in the NAT table to see if addresses should
be Natted.
in this case the source IP address matches an entry in the table. So, the source
IP address is going to be changed to 1.1.1.2 , the destination address is not
going to be changed, it's going to remain as 2.2.2.2.
The router will change the source address and then forward the traffic to the
Internet,
The source address matches the same entry of 10.1.1.1 and the destination address matches
this entry to 2.2.2.2. So, the router is going to change the source IP address to 1.1.1.2 as per
the inside global entry in the NAT table.
In this example the outside local and outside global addresses are the same.
So, the router doesn't change the destination address in the packet.
If you sniffed the traffic using wireshark on this link from the router to the
internet, you would see that the source address is set now to 1.1.1.2 rather
than 10.1.1.1 which it was set to, on the inside network.
when the traffic arrives at the server and the server receives the traffic. The server believes
that it's talking with a host with an IP address of 1.1.1.2, the server never sees that the actual
source IP address was 10.1.1.1.
->when the server replies, the source and destination addresses are swapped
around.
So, the source address is now 2.2.2.2 and the destination address is now
10.1.1.2. The packet is now routed across the Internet and arrives at the
NAT router.
When the router receives the traffic, it sees that the traffic is destined to not be address of
1.1.1.2. The router will check in its NAT table whether it has a matching entry, in this case it
does.
The inside global address is 1.1.1.2 which matches the destination address.
So, what the router will do is it will NAT the IP address 1.1.1.2 and change it
to 10.1.1.1 before forwarding the traffic on to the local network.
The source address of 2.2.2.2 is not changed because those entries are the
same in the NAT table for outside local and outside global.
So once again if you sniffed the traffic between the route and the PC, you would see
that the destination address is 10.1.1.1, source address is 2.2.2.2, and that's because
the router has changed the destination IP address based on the inside local entry.
Now that's essentially how NAT works. This is a simple one to one mapping with basic NAT.
Part 23
The Router NAT’s that's ingress traffic based on the inside global table.
So, traffic destined to 1.1.1.1 port 1024 is changed to 10.1.1.1 port 1024 and
forwarded on to the local segment
traffic destined to 1.1.1.1 port 1025 is translated to 10.1.1.2 port 1024 and forwarded
on to the local segment.
The PCs as well as the server are unaware that their traffic has been natted. They are
essentially oblivious to the changes that have been made by the router to the IP addresses
and port numbers. Traffic is routed correctly PCs are unaware of what's going on and that's
essentially how much overloading
or port address translation or Pat works.
Cheat Sheet:
Cheat Sheet:-
Inside Local = Inside Local addresses are used by the hosts on the inside network to
communicate with other host on the same network. These inside local addresses are translated
into global address.
Outside Global = Outside Global address are the addresses assigned by NAT on the remote
network.
Outside Local = Outside Local address are the actual addresses of the hosts on the remote
network
Neil Andreson
Inside Local address = The IP address actually configured on the inside host's Operating System
Inside Global address = The NAT'd address of the inside host as it will be reached by the outside
network
Outside local address = The IP address of the outside host as it appears to the inside network.
Outside Global address – The IP address assigned to the host on the outside network by the
host’s owner.