-: If you think back to our lesson on IP addressing, 2 2
specifically with version four, 3 3
we talked about the fact, that IPv4 4 4
was running out of IP addresses, 5 5
and this was becoming a huge problem. 6 6
Now, IPV six, honestly, wasn't ready yet to be developed. 7 7
And they were still in the process of it. 8 8
And so, something else had to come up, 9 9
to help us with this problem. 10 10
And that is what address translation did. 11 11
It was there, to help solve this problem for us. 12 12
And there was two versions of this, 13 13
Network Address Translation and Port Address Translation. 14 14
Now, Network Address Translation is a way for us, 15 15
to conserve those limited number of IPv4 addresses. 16 16
For example, if I go to your house right now, 17 17
how many devices do you have on your network? 18 18
You might have five or ten or fifteen. 19 19
In my house, we each have a smartphone, a tablet, 20 20
a laptop, a desktop, some video game machines, 21 21
and there's four of us. 22 22
So right there, we've got twelve, fifteen, 23 23
twenty devices, right? 24 24
Now, if you start adding things up, 25 25
like, smart thermostats, and file servers and desktops, 26 26
we quickly get to twenty or thirty or forty devices 27 27
in any single house. 28 28
But, in each house, we only have one public IP addresses. 29 29
So, how do all these devices get onto the internet? 30 30
Well, that is where NAT and PAT come into play. 31 31
Now, NAT or Network Address Translation is going 32 32
to allow you to translate your private IP address 33 33
into a public IP address, 34 34
for routing over the public networks, like the internet. 35 35
Now, there's another variation out there known as PAT, 36 36
which is Port Address Translation. 37 37
And we're going to talk about that 38 38
at the end of this video too. 39 39
Now, when we talk about different types 40 40
of address translation, there are three main ones out there. 41 41
There is DNAT, SNAT and PAT. 42 42
let's take each one, one at a time. 43 43
Let's start out with DNAT, 44 44
or Dynamic Network Address Translation. 45 45
Now, Dynamic NAT (DNAT) is going to take an IP address, 46 46
and automatically assign it from a pool of IP addresses, 47 47
and give us a one-to-one translation. 48 48
Now, why would we want to use Dynamic NAT (DNAT)? 49 49
Well, if you remember, I talked about the fact, 50 50
that public IP addresses cost money. 51 51
Maybe, you only wanted to pay 52 52
for five addresses in your business, 53 53
but you have thirty workstations there. 54 54
Well, in the old days, only 20% of your people 55 55
were going online at any time, 56 56
and so, Dynamic NAT (DNAT) worked out really well for that. 57 57
The way dynamic NAT would work, 58 58
is when you want to get online, 59 59
your computer, would go to the router, 60 60
it would borrow one of these five IP addresses, 61 61
it would do a translation from your private IP 62 62
to your public IP and that way you'd be able to use it. 63 63
Go online, make the request and then when you're done, 64 64
your computer turned that public IP, 65 65
back into the router, back to the shared pool. 66 66
This way you can maximize your public IP space 67 67
for the most amount of internal clients. 68 68
And it did all of this dynamically and you didn't have to 69 69
worry about it. 70 70
Just like it does with DHCP, to give you internal addresses, 71 71
this was all done, from a matching of an internal scope 72 72
to an external scope. 73 73
And so, in just a quick microsecond, 74 74
you could then take this address, make the request, 75 75
and then give it back. 76 76
Now, if you want to think about this, like a family, 77 77
let's say you have a mom and a dad, 78 78
and two teenagers living in the house, 79 79
but you only have two cars. 80 80
Well, if somebody wants to go the mall, 81 81
they would grab the car keys, get in the car, drive out, 82 82
and then when they're done, they'd bring the car back 83 83
and put the keys back up, 84 84
and then somebody else can grab the keys 85 85
and take out the car. 86 86
That's the way Dynamic NAT (DNAT) worked. 87 87
Now, when we're dealing with Static NAT or (SNAT), 88 88
this was a static assignment, 89 89
where I would manually assign a private IP to a public IP 90 90
and each time it was a one-to-one translation. 91 91
So, in this case, if I had five public IP addresses, 92 92
I would also have five private ones, 93 93
and I couldn't multi share them 94 94
the way I could with Dynamic NAT (DNAT). 95 95
So, in this case, I have to have one car 96 96
for every person, right? 97 97
Somebody has to physically do all that assignment as well, 98 98
because it's done statically. 99 99
Now, why would somebody want to use Static NAT (SNAT)? 100 100
You may be wondering, 101 101
cause it seems kind of like a silly way to do it, 102 102
when Dynamic NAT (DNAT) was available. 103 103
Well, Static NAT (SNAT) was really used 104 104
just as a security feature. 105 105
It was a way to have all those public IP's, 106 106
not shown, exactly which client was attached 107 107
to each one, to the outside world. 108 108
And so, it added a little bit of a smoke screen, 109 109
if you will, that kind of hid those devices 110 110
behind the router. 111 111
Now, the third way, and the most common one 112 112
that we use today is what's known as 113 113
PAT or Port Address Translation. 114 114
In fact, as you're watching this video, 115 115
you're probably using PAT on your home network right now, 116 116
without even knowing it. 117 117
Now, this is what happens when you have multiple private 118 118
IP addresses, sharing only one public address. 119 119
Now, again, my house, we have fifteen 120 120
or twenty different network devices, 121 121
but, we only have one public IP. 122 122
Now, the problem is all of us want 123 123
to get online at the same time, right? 124 124
We don't want to have to share that one IP. 125 125
Well, by using PAT, we can do that, 126 126
because it allows a many-to-one translation, 127 127
instead of the one-to-one, the Dynamic NAT (DNAT) 128 128
and Static NAT (SNAT) required. 129 129
Now, this is a great thing, 130 130
because it allows me to take these small networks, 131 131
like small offices, and home offices and small businesses, 132 132
and be able to connect them through one IP, 133 133
out to the internet. 134 134
Now, I'm going to show you how this works 135 135
by using a diagram, in just a second, so bear with me. 136 136
Now, before we do that though, 137 137
I want to talk about the different names 138 138
of the NAT IP addresses. 139 139
They have specific names that you have to memorize 140 140
for the exam. 141 141
There's the Inside local, Inside global, 142 142
Outside local and Outside global. 143 143
For your inside local, this is your private IP address 144 144
that references an inside device. 145 145
For your inside global, this is your public IP address 146 146
or your global one that's being referenced 147 147
for an inside device. 148 148
For your outside local, this is your private IP address, 149 149
that's being referenced from the outside 150 150
and you have your global device 151 151
or your outside global is coming to be a public IP address, 152 152
referencing that outside device. 153 153
Now again, anytime you see the word global, 154 154
I want you to think about public. 155 155
Anytime you see the word local, 156 156
I want you to think about private, 157 157
and then you'll be able to answer these types of questions. 158 158
Now, let me show you what all this looks like on a diagram. 159 159
Here, I have NAT. Now, where are each of these things? 160 160
If I'm dealing with my inside local, 161 161
that is my private IP address referencing an inside device, 162 162
which is one of the private IP addresses, 163 163
referencing an inside device in this diagram. 164 164
Well, there might be something like 10.0.1.101. 165 165
Which would be PC1, that is my inside local address. 166 166
Then, I have to reference an inside global address, 167 167
which is a router. 168 168
And for our case, that would be 78.1.45.1 169 169
It's inside, because it's my network, 170 170
and it's global because it's public. 171 171
As far as the outside local, that's our private IP address 172 172
that references an outside device. 173 173
For us, that would be the inside of this router, 174 174
or, 10.0.1.1 because that is our outside device, 175 175
it's our boundary device, that router. 176 176
And then, if I wanted to talk about my outside global, 177 177
that's my public IP address, referencing an outside device. 178 178
That would be the server, 66.75.58.124 179 179
All four of these, have to work together, 180 180
for us to be able to get the information 181 181
from RPC, 10.0.1.101, 182 182
from that local private IP address, 183 183
out to the server, that I want to make the connection to. 184 184
Now, how does NAT work? 185 185
Well, let's take a look at this diagram, 186 186
where I have PC1 and PC2, 187 187
who want to make a request of a single server. 188 188
Now PC1 and PC2, both have private IP addresses, 189 189
which are not routable outside my network. 190 190
Once, I get to the router, they're going to be dropped, right? 191 191
So, when they send a request, from their source IP, 192 192
that's their private IP. 193 193
That would be the 10.0.1.101 194 194
or 195 195
10.0.1.102 196 196
Now, as part of that request, 197 197
they're going to put the destination of the server 198 198
that they want to get to. 199 199
And so, they're going to send that request 200 200
with their default gateway, over to the router. 201 201
And this is where the NAT happens, 202 202
because it's a NAT enabled router. 203 203
When the router gets that request, 204 204
it's going to keep track of the fact that 10.0.1.101 205 205
was for PC1 206 206
and the.102 was for PC2. 207 207
And it's going to assign each of them, 208 208
an inside global address from its pool 209 209
of public IP addresses. 210 210
In this case, that 78.1.45.101 211 211
and 78.1.45.102 212 212
Now, it's going to strip off the source, 213 213
that was those private IP addresses 214 214
and put on these inside global addresses, 215 215
which is publicly routable. 216 216
And then, they're going to send the packet off to the server. 217 217
When the request comes back to the router, 218 218
it's going to strip off those inside global addresses, 219 219
put back on the inside local addresses 220 220
and send it back to PC1 and PC2, respectively. 221 221
That's essentially how NAT works 222 222
and this can be either done statically or dynamically 223 223
based on those IP addresses and the pool that's 224 224
being there, in reserve, at that NAT enabled router. 225 225
Now, when we deal with your network at home though, 226 226
we're using PAT, 227 227
Like I said before. This is port address translation. 228 228
The reason for this is it only requires 229 229
one IP address on your router. 230 230
Now, you can't just take one and give it directly 231 231
to PC1 or PC2 though, 232 232
because, then, only one of them can get online at a time. 233 233
So instead, We're going to use ports, 234 234
to keep track of the different segments that we're doing. 235 235
So, when PC1 and PC2, make a request to the router, 236 236
the router is going to send off a request 237 237
from its source address. 238 238
and it's going to specify a port number, 239 239
to keep track of those requests. 240 240
When the request comes back from the server 241 241
on that specific port, 242 242
it then knows, I need to take that traffic 243 243
and forward it to either PC1 or PC2, respectively, 244 244
depending on which port number it was. 245 245
And that's why PAT is so popular today, 246 246
because we only have to have one public IP, 247 247
and we can have twenty, fifty, a hundred devices, 248 248
all sitting behind that router, 249 249
and being kept track of based on those ports.