NAT (part 2)
Synchronized Transcript
142 cues indexed • Click dialogue or words to jumpWelcome to Jeremy’s IT Lab. This is a free, complete course for the CCNA. If you like these videos, please subscribe to follow along with the series.
Also, please like and leave a comment, and share the video to help spread this free series of videos. Thanks for your help. In this video we will finish up the topic of NAT, Network Address Translation.
NAT is topic 4.1 of the CCNA exam. In Day 44 I introduced NAT and covered static NAT, but this video will focus on dynamic NAT.
After this video, I think you’ll have no problems answering any NAT questions on the CCNA exam. Here’s what we’ll cover in this video.
First, I will cover one more point about static NAT that I didn’t mention in the last video. Then I’ll cover dynamic NAT, in which you don’t manually map addresses one-to-one, but instead the router automatically makes the mappings for you.
And then another very important type of NAT, dynamic PAT, which translates not only the IP address, but also the port number. Dynamic PAT is extremely useful because it allows many devices to share a single public IP address.
As always, watch until the end of the video for a bonus practice question from Boson Software’s ExSim for CCNA. First, some review about static NAT.
Static NAT involves statically configuring one-to-one mappings of private IP addresses to public IP addresses. When traffic from the internal host is sent to the outside network, the router will translate the source address.
So, I have mapped inside local address 192.168.0.167 to inside global address 100.0.0.1, and also mapped 192.168.0.168 to 100.0.0.2 Then, if for example if PC1 wants to access the server at 8.8.8.8,
it sends a packet with source IP 192.168.0.167, a private IP address. R1 then translates the source address to 100.0.0.1, a public IP address.
When the server sends its reply, the destination is the public IP address. R1 translates the destination IP of the reply back to 192.168.0.167 and forwards it to PC1.
Okay, hopefully you understand this process by now, but let me demonstrate one other important point about static NAT.
This one-to-one mapping of IP addresses doesn’t only allow the internal host to access external resources, it also allows external hosts to access the internal host via the inside global address.
So, without PC1 initiating communication with the server, it could send a packet to destination IP 100.0.0.1, and because of that one-to-one IP address mapping R1 would translate it to 192.168.0.167 and forward it to PC1, and then PC1 would reply.
So, it works two-ways, not just from inside to outside, but also from outside to inside. Okay, just wanted to make that clear since I didn’t mention it in Day 44.
Now let’s move on to dynamic NAT. In dynamic NAT, the router dynamically maps inside local addresses to inside global addresses as needed.
So, you don’t manually specify ‘map this IP address to this IP address, that IP address to that IP address’. The router makes those mappings automatically, and then clears the mapping when its no longer needed.
Here’s how it works in Cisco IOS. An ACL is used to identify which traffic should be translated. Okay, this part is important, because it’s a totally different use of an ACL, but it’s a very common use.
ACLs can be used to indicate which traffic should be forwarded and which should be blocked, you already know that. But they can also be used just to identify traffic.
If the source IP of a packet is permitted by the ACL, the source IP will be translated by NAT. However if the source IP is denied by the ACL, the source IP will NOT be translated.
But that doesn’t mean the traffic will be dropped! We’re simply using the ACL to identify which traffic should be translated, we’re not using it to drop traffic, because we won’t apply the ACL to an interface with the IP ACCESS-GROUP command.
Anyway, when we get to configuration you’ll see how it works. Then, a NAT pool is used to define the available inside global addresses that can be used for translation.
For example, on R1 I configured ACL 1, which permits 192.168.0.0/24 and denies all other traffic.
I also configured NAT POOL1, with a range from 100.0.0.1 to 100.0.0.10. That means if a packet with a source IP permitted by ACL 1 arrives, translate the source IP to an address from POOL1.
So, PC1 sends a packet, and its IP address is permitted by ACL 1. Then R1 translates the source IP to an address from POOL1, 100.0.0.1.
The server sends a reply, and R1 translates the address back. So, it looks like the same process as in static NAT.
The difference is that, instead of manually configuring a mapping from 192.168.0.167 to 100.0.0.1, R1 did it automatically when the packet from PC1 arrived.
Now, I want to emphasize this point. If the source IP address is not permitted by the ACL, it doesn’t mean the packet will be dropped, it just means it won’t be translated.
Let me explain a few more points about dynamic NAT, and then we’ll look at the configuration. Although they are dynamically assigned, the mappings are still one-to-one, one inside local IP address per inside global IP address.
If there aren’t enough inside global IP addresses available, if they are all currently being used, it is called ‘NAT pool exhaustion’.
In the previous example, the ACL specified a /24 subnet of inside local addresses, but the NAT pool only had 10 inside global addresses.
So, there can only be 10 translations active at a time. What happens if there are no available addresses, but a packet arrives and needs NAT?
If a packet from another inside host arrives and needs NAT but there are no available addresses, the router will drop the packet. The host will be unable to access outside networks until one of the inside global IP addresses becomes available.
And how does that happen? Dynamic NAT entries will time out automatically if not used, or you can clear them manually. So, in our previous example if PC1 stops communicating with external hosts for a while, the inside global address 100.0.0.1 would become available
again for a different host to use. Or you can use the CLEAR IP NAT TRANSLATION command anytime to manually clear translations.
Let me demonstrate that NAT pool exhaustion. A packet with source IP 192.168.0.167 arrives at R1. It is translated to 100.0.0.1, and then forwarded.
A packet with source IP 192.168.0.168 arrives and is translated to 100.0.0.2, and then forwarded. Some other hosts send traffic, and now those ten inside global IP addresses, 100.0.0.1 through.10, are all being used.
If host 192.168.0.98 tries to send some traffic to the Internet, what happens? There are no addresses available, so the router will drop the packet.
But, perhaps 192.168.0.167 stops communicating over the Internet. After some time, its dynamic translation is removed.
If 192.168.0.98 tries to send that traffic again, , the 100.0.0.1 address is now available and it can reach the Internet. So, that’s a difference between static NAT and dynamic NAT.
Although both are one-to-one mappings, static NAT mappings are permanent. However dynamic NAT mappings are temporary, they will time out when they are no longer needed, and then another host can use that same public IP address.
However, hosts are still unable to use the same public IP address at the same time. To do that, you have to use PAT, Port Address Translation.
But before looking at Port Address Translation, let’s cover dynamic NAT configuration. First, just like in static NAT you must define the inside and outside interfaces.
Then define the traffic that should be translated. As I mentioned before, traffic permitted by this ACL will be translated. So, this ACL tells R1 to translate all traffic from 192.168.0.0/24.
Then define the pool of inside global IP addresses. The command is IP NAT POOL, then the pool name. After that you specify the first IP address in the range, and then the last IP address in the range.
So I specified a range from 100.0.0.0 to 100.0.0.255. Finally, you have to specify the prefix length, either with the PREFIX-LENGTH option or the NETMASK option.
IOS uses this to check if both addresses, the first and last address of the range, are in the same subnet. If they aren’t, the command will be rejected.
Finally, configure dynamic NAT by mapping the ACL to the pool, with IP NAT INSIDE SOURCE, and then instead of STATIC use LIST, followed by the ACL number or name, and then POOL, followed by the pool name.
And that’s all there is to dynamic NAT configuration. It’s a bit more complicated than static NAT configuration, but it’s not so difficult. So, with the configurations complete I sent some traffic from PC1 and PC2 to 8.8.8.8.
Let’s check out R1’s translation table. So, here’s R1’s table after sending pings as well as DNS traffic to the server at 8.8.8.8.
Notice there are three entries for each mapping, three for 192.168.0.167 to 100.0.0.1, and three for 192.168.0.168 to 100.0.0.2.
When the router dynamically creates the inside local to inside global mappings, these entries are created. And then when those mappings are actually used, when translations are made, separate entries like these UDP entries or these ICMP entries are
made. Now, those UDP and ICMP entries will be cleared after about a minute, but the original dynamic mappings themselves have a default timeout value of 24 hours, and each time a translation is made the timer resets.
So, dynamic NAT mappings actually last quite a long time. You can change the default timers if you want, but that’s not something you need to know for the CCNA.
Note that, although these entries look like the static NAT entries from Day 44, if I use the CLEAR IP NAT TRANSLATION command, these entries will be cleared because they are not static, they are dynamic.
Now here’s SHOW IP NAT STATISTICS. Note that I entered this command when all 6 of those translation entries were active, so it displays 6 total active translations.
6 dynamic entries, and 4 extended. So, all of those entries were dynamic, but can you guess which ones are the extended entries?
They are those UDP and ICMP temporary entries that were cleared after a minute. But again, the details of extended entries aren’t something you need to know for the CCNA.
What I really want to point out here is that you can confirm the dynamic mapping from ACL 1 to POOL1 here. So, just like with static NAT, the two SHOW commands you should know for dynamic NAT are SHOW IP NAT TRANSLATIONS and SHOW IP NAT STATISTICS.
You should be familiar with both of these commands for the CCNA exam. Now let’s move to PAT, Port Address Translation, which is also known as NAT overload.
It translates both the IP address and the port number of a packet, if necessary. And what’s the purpose of translating the port number?
By using a unique port number for each communication flow between internal hosts and external hosts, a single public IP address can be used by many different internal hosts.
TCP and UDP port numbers are 16 bits in length, which means there are over 65,000 port numbers. Then, the router will keep track of which inside local address is using which inside global address and port.
So, the router will keep track of the communication flows by using unique port numbers for each flow. Let me demonstrate. PC1 sends a DNS message to 8.8.8.8.
Its source IP is 192.168.0.167, and it selects a random source port, 54321. PC2 also sends a DNS message to 8.8.8.8, with source IP 192.168.0.168.
It also selects a random source port, and it happens to choose the same source port as PC1, 54321. R1 translates the source IP of PC1’s message to 100.0.0.1, and keeps the source port the same, 54321.
For PC2’s message, it also translates the source IP to 100.0.0.1, but it changes the source port to 54322.
Why does it do that? It’s so it can keep track of the communication flows. If both flows use the same source IP and source port, when the replies come from the server, R1 won’t know which reply to send to which PC.
So, the server sends the replies to R1. Both have destination IP 100.0.0.1, but one has destination port 54321, and the other 54322.
Because of the unique port numbers, R1 knows to send this reply to PC1 and this reply to PC2. In this example, both PCs selected the same random source port number, because I wanted to show the router translating the source port.
However, if PC2 selected a different random source port than PC1, then R1 would have no need to translate the source port. It would simply use the source port PC2 selected and use that to keep track of the sessions.
So, that’s how PAT works. Because many inside hosts can share a single public IP, PAT is very useful for preserving public IP addresses, and it is used in networks all over the world.
Of the three types we have covered, static NAT, dynamic NAT, and PAT, PAT is the most widely used because it allows so many inside hosts to share a single public IP address.
Here’s how to configure PAT. It’s basically the same as dynamic NAT, you just add one keyword. So, first define the inside and outside interfaces.
Then, define which traffic should be translated by using an ACL. Again, traffic permitted by the ACL will be translated.
Then define the pool of inside global IP addresses. This time I defined a smaller range, from 100.0.0.0 to 100.0.0.3.
Chances are, unless the internal network is very large, you won’t need more than a single IP address, but this provides some scalability, some room for growth.
Note that I still specified a prefix length of 24 bits. As long as the specified address range is in the same subnet, this specified prefix length doesn’t really matter.
100.0.0.0 through 100.0.0.3 all fit in the subnet 100.0.0.0/24, so the command is valid. Finally, the NAT statement itself.
It’s the same as for dynamic NAT, except at the end you use the keyword OVERLOAD. IP NAT INSIDE SOURCE LIST 1 POOL POOL1 OVERLOAD.
So, PC1 and PC2 both send DNS requests to 8.8.8.8. Let’s take a look at the NAT translations and statistics on R1.
So, here are the translations on R1. One big difference compared to regular dynamic NAT is that those one-to-one dynamic mapping entries aren’t displayed.
That’s because, when using PAT, there are no one-to-one mappings, they’re many to one. Many inside local addresses to one inside global address.
As you can see, both 192.168.0.167 and .168 are using 100.0.0.1. They both selected different source port numbers, so R1 didn’t need to translate the port numbers.
It will use port number 63925 to track the communication flow between PC1 and 8.8.8.8, and it will use port number 59549 to track the communication flow between PC2 and 8.8.8.8.
And here’s SHOW IP NAT STATISTICS. Feel free to pause the video to check out the output if you’re interested, but now I’m going to move on to show you one more useful way to configure PAT.
One more way to configure PAT, and probably the more common way, is to configure the router to use its own public IP address when translating the source IP of packets.
So, as always you must configure the inside and outside interfaces on the router. And then just like before use an ACL to define which traffic should be translated.
Here’s the difference with the previous method of configuring PAT. Instead of specifying a POOL and then the OVERLOAD keyword, you specify INTERFACE, then the outside interface, g0/0 in R1’s case, and then OVERLOAD.
So, R1 will translate the source IP address of packets from 192.168.0.0/24 to the IP address of its G0/0 interface, 203.0.113.1.
It will also use a unique source port number for each traffic flow, so it can keep track of them and multiple internal hosts can share that single IP address.
Let me demonstrate that. PC1 and PC2 both send DNS requests to 8.8.8.8. Notice that they both selected a different random source port.
65205 for PC1 and 59641 for PC2. R1 translates the source IP address of both packets, changing them to the IP of R1’s G0/0 interface, 203.0.113.1.
Because both source port numbers are already different, there is no need to translate the port numbers. The server sends the replies, and R1 translates them back and sends them to their correct destinations.
Because of the unique port numbers, R1 knows which to translate back to 192.168.0.167 and which to translate back to 192.168.0.168.
Here is R1’s NAT translation table after that. Notice that both 192.168.0.167 and .168 are using R1’s IP address, 203.0.113.1.
Also notice that, as I said, there was no need for R1 to translate the source port numbers, because they were already unique. And here is SHOW IP NAT STATISTICS.
Again, feel free to pause and check this command out if you want, but going in depth into all of the output here isn’t necessary. Here are the new commands we covered in this video.
If you don’t remember these commands, go back in the video to review, and also make sure to practice them in packet tracer either by making your own labs or by doing my practice labs.
Before moving on to the quiz, let’s review what we covered in this video. First, I demonstrated how static NAT not only allows inside hosts to access external networks, but it also allows hosts on external networks to access the internal hosts using the mapped inside global IP address.
Then I covered dynamic NAT and dynamic PAT. Dynamic PAT is probably the most common type of NAT. It allows many internal hosts to share a single public IP, all at the same time.
My home router, for example, has a single public IP address, and all of the devices in my home such as my PC, phones connected to Wi-Fi, etc, all share the single public IP address when accessing the Internet.
And make sure to watch until the end of the quiz for a bonus question from Boson Software’s ExSim for CCNA. Okay, let’s go to quiz question 1.
Which of the following NAT types best fulfills the goal of preserving public IPv4 addresses? Pause the video now to think about your answer.
Okay, the answer is D, NAT Overload, aka PAT. NAT Overload allows many internal hosts to use a single public IP address because the router keeps track of communication flows using the Layer 4 port number.
This means most networks only need a single public IP address, instead of each device requiring a unique public IP address. Okay, let’s go to question 2.
Which of the following dynamic NAT configurations will translate inside local addresses from 172.16.1.0/24 to addresses from the subnet 203.0.113.0/25?
Pause the video now to think about the answer. Okay, the answer is B.
So, what’s wrong with A and C? In A, the pool’s netmask is correct, 255.255.255.128 is /25, but the address range is 203.0.113.0 to 203.0.113.255.
203.0.113.255 does not fall in the 203.0.113.0/25 subnet, so the router would reject this command.
How about C? The ACL’s mask is 255.255.255.0, but ACLs are supposed to use wildcard masks, so /24 should be 0.0.0.255.
Okay, let’s go to question 3. Dynamic NAT is configured on R1 and a pool of 10 inside global addresses is specified.
Currently, all 10 addresses are being used by inside hosts, but another inside host attempts to send a packet over the Internet. What does R1 do with this packet?
Pause the video now to think about the answer. Okay, the answer is B, it discards the packet.
When dynamic NAT is being used and a packet requires NAT, but there are no available addresses in the pool, the router will simply discard the packet.
Okay, let’s go to question 4. Which of the following dynamic NAT configurations will translate inside local addresses from 10.0.1.0/27 to use the IP address of the router’s G0/1 interface?
Pause the video now to think about the answer. Okay the answer is A. It’s the only option that uses the correct /27 wildcard mask in the ACL, the correct IP NAT command, and assigns the inside and outside
interfaces correctly. Okay, let’s go to question 5. After specifying the inside and outside NAT interfaces, you issue the following commands on R1.
What will happen to hosts from the 192.168.1.0/24 subnet? Pause the video now to think about the answer.
Okay, the answer is C, the packets they send will not be translated by R1. When an ACL is used to identify which traffic should be translated, such as in dynamic NAT and PAT, packets permitted by the ACL will be translated, and packets denied by the ACL won’t be translated.
Even though the ACL denies the packets, it doesn’t mean the router will drop the packets, it just won’t translate them. Okay, that’s all for the quiz.
Now let’s take a look at a bonus question from Boson Software’s ExSim for CCNA. Okay, here's today's Boson ExSim practice question.
HostA is attempting to initiate an HTTP connection to HostB through a NAT router named RouterA. The devices use the following IP addresses.
Here they are. Which of the following lines of output would you expect to be displayed when you issue the SHOW IP NAT TRANSLATIONS command on RouterA? Select the best answer.
Okay, pause the video now. Take a look at these options and select the best answer.
Okay let's check. So, first off, what should the outside local and outside global addresses be? They should be the IP address of the destination host, that is HostB, 192.0.2.28.
So all of these are correct. Now how about the inside local address, what should that be? That should be the IP address of the source host, so the actual IP address configured on HostA in this case.
So, 10.1.7.7. So that means A and D are incorrect. Their inside local address is 10.1.7.1, which is the IP address of RouterA's internal interface, and that is not correct.
So, the correct answer is either B or C. Now, how about the inside global IP address? Should that be 10.1.7.1, like in B, or 203.0.113.62?
So, 10.1.7.1 is the IP address of RouterA's internal interface, and 203.0.113.62 is the IP address of RouterA's external interface.
Now, when doing PAT and translating to the IP address of the router's interface, you should translate to the IP address of the external interface, the public IP address.
So, that means C is the correct answer. So I will click on show answer and indeed that is correct. So, here is Boson's explanation of that answer.
You can pause the video now to read this explanation. And there's some more down here.
Okay, so that was a quick look at Boson Software's ExSim for CCNA. These are without a doubt the best practice exams for the CCNA, and I highly recommend them. If you want to get Boson ExSim, please follow the link in the video description.
There are supplementary materials for this video. There is a flashcard deck to use with the software ‘Anki’. There will also be a packet tracer practice lab so you can get some hands-on practice.
That will be in the next video. Sign up for my mailing list via the link in the description, and I’ll send you all of the flashcards and packet tracer lab files for the course.
Before finishing today’s video I want to thank my JCNP-level channel members. To join, please click the ‘Join’ button under the video.
Thank you to Anand, Pavel, Abraham, Serge, Njoku, Viktor, Roger, Raj, Kenneth, Seamus, H W, Brandon, Aaron, Marcel, Kone, Donald, C Mohd, Gustavo, Anthony, Benjamin, Justin, Prakaash, Nasir, Erlison, Marko, Daming, Ed, Value, John, Funnydart, Velvijaykum,
Mark, Yousif, Boson Software, Devin, Lito, Yonatan, and Vance. Sorry if I pronounced your name incorrectly, but thank you so much for your support.
This is the list of JCNP-level members at the time of recording by the way, March 24th 2021. If you signed up recently and your name isn’t on here don’t worry, you’ll be in future videos.
Thank you for watching. Please subscribe to the channel, like the video, leave a comment, and share the video with anyone else studying for the CCNA. If you want to leave a tip, check the links in the description.
I'm also a Brave verified publisher and accept BAT, or Basic Attention Token, tips via the Brave browser. That's all for now.