If you think back to our lesson
on IP addressing specifically with version four,
we talked about the fact
that IPv4 was running out of IP addresses,
and this was becoming a huge problem.
Now, IPv6 honestly wasn't ready yet to be developed,
and they were still in the process of it.
And so something else had to come up to help us
with this problem, and that is what address translation did.
It was there to help solve this problem for us,
and there was two versions of this,
Network Address Translation and Port Address Translation.
Now, Network Address Translation is a way for us
to conserve those limited number of IPv4 addresses.
For example, if I go to your house right now,
how many devices do you have on your network?
You might have 5 or 10 or 15.
In my house, we each have a smartphone, a tablet, a laptop,
a desktop, some video game machines, and there's four of us.
So right there, we've got 12, 15, 20 devices, right?
Now, if you start adding things up like smart thermostats
and file servers and desktops, we quickly get to 20 or 30
or 40 devices in any single house.
But in each house, we only have one public IP addresses.
So how do all these devices get onto the internet?
Well, that is where NAT and PAT come into play.
Now, NAT, or Network Address Translation is going
to allow you to translate your private IP address
into a public IP address for routing
over the public networks like the internet.
Now, there's another variation out there known as PAT,
which is Port Address Translation,
and we're going to talk about that
at the end of this video too.
Now, when we talk about different types
of address translation, there are three main ones out there.
There is DNAT, SNAT, and PAT.
Let's take each one one at a time.
Let's start out with DNAT,
or Dynamic Network Address Translation.
Now, dynamic NAT is going to take an IP address
and automatically assign it from a pool of IP addresses
and give us a one-to-one translation.
Now, why would we want to use dynamic NAT?
Well, if you remember, I talked about the fact
that public IP addresses cost money.
Maybe you only wanted to pay
for five addresses in your business,
but you have 30 workstations there.
Well, in the old days, only 20%
of your people were going online at any time,
and so dynamic NAT worked out really well for that.
The way dynamic NAT would work is when you wanted
to get online, your computer would go to the router,
it would borrow one of these five IP addresses,
it would do a translation from your private IP
to your public IP,
and that way you'd be able to use it, go online,
make the request, and then when you're done,
your computer turned that public IP back into the router,
back to the shared pool.
This way, you can maximize your public IP space
for the most amount of internal clients,
and it did all this dynamically
and you didn't have to worry about itm
just like it does with DHCP to give you internal addresses,
this was all done from a matching
of an internal scope to an external scope.
And so in just a quick microsecond,
you could then take this address,
make the request, and then give it back.
Now, if you want to think about this like a family,
let's say you have a mom and a dad
and two teenagers living in the house,
but you only have two cars.
Well, if somebody wants to go to the mall,
they would grab the car keys, get in the car, drive out,
and then when they're done, they bring the car back
and put the keys back up,
and then somebody else can grab the keys
and take out the car.
That's the way dynamic NAT worked.
Now, when we're dealing with static NAT, or SNAT,
this was a static assignment
where I would manually assign a private IP to a public IP,
and each time it was a one-to-one translation.
So in this case, if I had five public IP addresses,
I would also have five private ones,
and I couldn't multishare them
the way I could with dynamic NAT.
So in this case, I have to have one car
for every person, right?
Somebody has to physically do all that assignment as well,
because it's done statically.
Now, why would somebody want to use static NAT?
You may be wondering 'cause it seems
like a silly way to do it when dynamic NAT was available.
Well, static NAT was really used just as a security feature.
It was a way to have
all those public IPs not showing exactly
which client was attached to each one to the outside world,
and so it added a little bit of a smokescreen, if you will,
that kind of hid those devices behind the router.
Now, the third way
and the most common one that we use today is what's known
as PAT or Port Address Translation.
In fact, as you're watching this video,
you're probably using PAT on your home network
right now without even knowing it.
Now, this is what happens
when you have multiple private IP addresses sharing
only one public address.
Now again, my house, we have 15
or 20 different network devices,
but we only have one public IP.
Now the problem is all
of us want to get online at the same time, right?
We don't want to have to share that one IP.
Well, by using PAT, we can do that,
because it allows a many-to-one translation instead
of the one-to-one that dynamic NAT and static NAT required.
Now, this is a great thing,
because it allows me
to take these small networks like small offices
and home offices and small businesses
and be able to connect them
through one IP out to the internet.
Now, I'm going to show you how this works
by using a diagram in just a second, so bear with me.
Now, before we do that though,
I want to talk about the different names
of the NAT IP addresses.
They have specific names that you have
to memorize for the exam.
There's the inside local, inside global, outside local
and outside global.
For your inside local,
this is your private IP address
that references an inside device.
For your inside global,
this is your public IP address
or your global one that's being referenced
for an inside device.
For your outside local,
this is your private IP address
that's being referenced from the outside.
And you have your global device,
or your outside global is coming
to be a public IP address referencing that outside device.
Now again, anytime you see the word global,
I want you to think about public.
Anytime you see the word local,
I want you to think about private.
And then you'll be able to answer these types of questions.
Now, let me show you what all this looks like on a diagram.
Here I have NAT.
Now where are each of these things?
If I'm dealing with my inside local,
that is my private IP address, referencing an inside device.
Which is one of the private IP addresses,
referencing an inside device in this diagram?
Well, that might be something like 10.0.1.101,
which would be PC1.
That is my inside local address.
Then I have to reference an inside global address,
which is a router, and for our case that would be 78.1.45.1.
It's inside because it's my network,
and it's global because it's public.
As far as the outside local, that's our private IP address
that references an outside device.
For us, that would be the inside of this router or 10.0.1.1,
because that is our outside device.
It's our boundary device, that router.
And then if I want to talk about my outside global,
that's my public IP address, referencing an outside device,
that would be the server 66.75.58.124.
All four of these have to work together for us to be able
to get the information from our PC, 10.0.1.101,
from that local private IP address out to the server
that I want to make the connection to.
Now, how does NAT work?
Well, let's take a look at this diagram
where I have PC1 and PC2,
who want to make a request of a single server.
Now, PC1 and PC2 both have private IP addresses,
which are not routable outside my network.
Once I get to the router, they're going to be dropped, right?
So when they send a request from their source IP,
that's their private IP, that would be the 10.0.1.101
or 10.0.1.102.
Now, as part of that request,
they're going to put the destination of the server
that they want to get to,
and so they're going to send
that request with their default gateway over to the router.
And this is where the NAT happens,
because it's a NAT-enabled router.
When the router gets that request, it's going to keep track
of the fact that 10.0.1.101 was for PC1
and the .102 was for PC2,
and it's going to assign each of them an inside global address
from its pool of public IP addresses.
In this case, that's 78.1.45.101
and 78.1.45.102.
Now it's going to strip off the source
that was those private IP addresses
and put on these inside global addresses,
which is publicly routable,
and then they're going to send the packet off to the server.
When the request comes back to the router,
it's going to strip off those inside global addresses,
put back on the inside local addresses,
and send it back to PC1 and PC2 respectively.
That's essentially how NAT works,
and this can be either done statically
or dynamically based on those IP addresses
and the pool that's being there in reserve
at that NAT-enabled router.
Now, when we deal with your network at home though,
we're using PAT, like I said before,
this is Port Address Translation.
The reason for this is it only requires one IP address
on your router.
Now you can't just take one and give it directly
to PC1 or PC2, though,
because then only one of them can get online at a time.
So instead, we're going to use ports to keep track
of the different segments that we're doing.
So when PC1
and PC2 make a request to the router,
the router's going to send off a request
from its source address,
and it's going to specify a port number
to keep track of those requests.
When the request comes back from the server
on that specific port,
it then knows I need to take
that traffic and forward it to either PC1
or PC2 respectively,
depending on which port number it was.
And that's why PAT is so popular today,
because we only have to have one public IP,
and we can have 20, 50,
a hundred different devices all sitting behind that router
and being kept track of based on those ports.