NAT (Part 1)
Synchronized Transcript
152 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 cover NAT, Network Address Translation.
NAT is a very important topic for the CCNA exam and for real-world network engineering. NAT is used to translate the source and/or destination IP address of a packet to a different IP address.
NAT is covered in exam topic 4.1, which says you must be able to configure and verify inside source NAT using static and pools.
Here’s what we’ll cover in this video. First, I’ll talk about private IPv4 addresses. These are IP addresses which you are free to use in your internal networks and which don’t have to be globally unique.
Then I’ll introduce NAT and its purpose. After that I’ll cover one type of NAT you need to know for the CCNA, static NAT, and how to configure it.
This video will be part 1 of NAT. I’ve decided to split NAT up into two videos instead of one long video, because it’s an important topic that I don’t want to rush.
So, in Day 45 I will cover some additional NAT topics you need to know for the CCNA. As always, watch until the end of the video for a bonus practice question from Boson Software’s ExSim, the best practice exams for the CCNA.
First let me introduce private IPv4 addresses. This is review from the IPv6 videos in this course, but IPv4 doesn’t provide enough addresses for all devices that need an IP address in the modern world.
The long-term solution to this problem is to switch to IPv6, but changing networks all over the world from IPv4 to IPv6 is no simple task.
So, before we switch completely over to IPv6, there are some short-term solutions to this problem, which have actually extended the lifespan of IPv4 quite a lot.
The first one, which you already know, is CIDR, Classless Inter-Domain Routing. With CIDR we can forget about the rigid IPv4 address classes and are free to use any prefix length with any address, no need to think about classes.
Then there are two other very important solutions which I will cover in this video. Private IPv4 addresses and NAT.
RFC 1918 specifies the following IPv4 address ranges as private. Now, before I show the address ranges, ‘RFC’ means Request For Comments.
These are the documents that are used to set standards for the Internet. I’ve mentioned that once or twice before I think, I just wanted to make it clear.
Okay, so the first private IPv4 address range is 10.0.0.0/8, which includes 10.0.0.0 to 10.255.255.255.
The second one is 172.16.0.0/12, which includes 172.16.0.0 to 172.31.255.255.
Finally there is 192.168.0.0/16, which includes 192.168.0.0 to 192.168.255.255. You probably recognize these address ranges, I use them a lot in my course for example networks and labs.
So, they specified one range of addresses from class A, one range of addresses from class B, and one range of addresses from class C.
Now, I’m sure some of you will be thinking ‘why is the class B range /12? Isn’t class B /16? And why is the class C range /16?
Isn’t class C /24’? The answer to those questions is that these are simply address ranges. 172.16.0.0/12 just specifies a range of addresses from 172.16.0.0 to 172.31.255.255,
and you’re free to divide up those addresses however you want and use them in your network. Likewise, 192.168.0.0/16 just specifies a range of addresses from 192.168.0.0 to 192.168.255.255, and once again you are free to divide up those addresses
in any way you want. In any case, don’t be too attached to the concept of address classes. In modern networks everyone uses CIDR, Classless Inter-Domain Routing, so address classes are a thing of the past.
So, those are the private IPv4 address ranges. You are free to use these addresses in your networks, they don’t have to be globally unique. In fact, if you’re watching this video from a PC in your home, it’s almost certainly using a private IP address.
For example, my PC has the IP address 192.168.0.167, and its default gateway, my router, is 192.168.0.1.
Your PC might have the exact same IP address as mine, or at least it might be in the same subnet, 192.168.0.0/24. Now, here’s an important point.
Private IP addresses cannot be used over the Internet. Your ISP, Internet Service Provider, will drop traffic to or from private IP addresses.
You may be wondering, if the private IP addresses can’t be used over the Internet, how can I access the Internet from my PC? That’s where NAT comes in.
Let me demonstrate. On the left is my PC, 192.168.0.167, connected to my router, 192.168.0.1. Somewhere across the Internet there is another PC connected to a router, and they have the same IP addresses.
Without NAT, there are two big problems here. The first is that there are duplicate addresses. If there is a packet traveling over the Internet with the destination address 192.168.0.167, which PC will it go to?
My PC? Or the other one with the same IP address? So, that’s a problem. Another problem is that private IP addresses can’t even be used over the Internet, so the PCs can’t access the Internet.
However NAT solves both of these problems for us. Although the PCs and the routers’ internal interfaces have identical private addresses, perhaps my router’s external interface has the public IP address 203.0.113.1, and the other router has the public
IP address 203.0.113.5. This is important. Although the private IP addresses aren’t unique, the public IP addresses must be unique.
When my PC needs to reach destinations over the Internet, NAT will allow it to borrow the unique public IP address of my router, or another public IP address I have configured for NAT.
In fact, not just my PC, but all other devices in my home can use that same single public IP address to access the Internet, all at the same time.
So my PC can borrow my router’s IP address and communicate over the Internet using 203.0.113.1, and the other PC can communicate over the Internet using 203.0.113.5.
Anyway, I’ll explain NAT next. Regarding private IP addresses, remember the RFC number 1918, remember the three private IP address ranges, and remember that they can’t be used over the Internet.
So let’s talk about NAT. NAT is used to modify the source and/or destination IP addresses of packets. And why would you want to do that? Well there are various reasons to use NAT, but the most common reason is to allow hosts with private IP addresses to communicate with other hosts over the
Internet, as I introduced in the previous That is in addition to allowing multiple internal hosts to share a single public IP address, but I’ll demonstrate how that works in day 45.
There are also various types of NAT, but for the CCNA you have to understand source NAT and how to configure it on Cisco routers. Let me give a brief demonstration of how source NAT works.
PC1’s IP address is 192.168.0.167, and it wants to communicate with the server at 8.8.8.8. So, it creates a packet with source IP 192.168.0.167 and destination 8.8.8.8.
It sends the packet to its default gateway, R1. This is where the NAT happens. R1 translates the source IP address from 192.168.0.167 to 203.0.113.1, the IP address of its external interface.
That’s why it’s called ‘source’ NAT, because it translates the source IP address. Note that, in this case R1 translated PC1’s IP to the IP address of its own interface, 203.0.113.1, but that’s only one option.
There are many different kinds of NAT. In fact, I’ll cover this type of NAT, where the router’s interface IP address is used, in the next video, day 45.
Static NAT, which I’ll cover in this video, doesn’t use the router’s IP address, it uses a separate address, which you’ll see in the next Anyway, R1 then sends the packet out to the Internet and it arrives at its destination, 8.8.8.8.
Now the server will send a reply. The source is 8.8.8.8, and the destination is 203.0.113.1.
It sends the packet to R1, which then reverses the translation. 203.0.113.1 is translated back to 192.168.0.167.
Although in this case the destination IP is being changed, this isn’t destination NAT. R1 is just reverting the previously translated address back to PC1’s actual IP address.
And then finally the server’s response reaches PC1. So, that’s a brief introduction to NAT, specifically source NAT, translating the source IP address of a packet.
Now let’s look deeper into one specific kind of source NAT, static source NAT. So, here’s static NAT. Static NAT involves statically configuring one-to-one mappings of private IP addresses to public IP addresses.
Now, it doesn’t have to be private to public. You can NAT any address to any other address, but to keep things simple let’s think of it as mapping one private IP to one public IP.
An inside local IP address is mapped to an inside global IP address. These are two important terms to understand, not just for static NAT but for all types of NAT I’ll introduce.
First, what does ‘inside’ mean? It refers to the router’s internal network, as opposed to outside networks such as the Internet. So, what is an inside local address?
It is the IP address of the inside host, from the perspective of the local network. So, it’s the IP address actually configured on the inside host, which is usually a private IP address.
That ‘inside local’ address is translated to an ‘inside global’ address, which is the IP address of the inside host from the perspective of ‘outside’ hosts, hosts outside of the local network.
So, that’s the IP address of the inside host after NAT, and is usually a public IP address. Let me demonstrate. PC1 wants to communicate with the server at 8.8.8.8.
So it makes a packet with destination IP address 8.8.8.8 and source IP address 192.168.0.167. This is the inside local address, it’s the IP address actually configured on PC1, and it is indeed a private IP address.
It sends the packet to its default gateway R1, which performs source NAT to change it to, for example, 100.0.0.1. Note that in static NAT we aren’t using R1’s interface IP, this is a separate public IP address reserved just for PC1.
This is the inside global IP of PC1. It’s PC1’s IP address after NAT is performed, and it’s a public IP address. R1 then sends the packet over the Internet to 8.8.8.8, which then sends the reply.
Note that, from the server’s perspective it’s communicating with IP address 100.0.0.1, even though PC1’s actual IP address is 192.168.0.167.
So, the ‘inside global’ address is the IP address of the inside host, PC1, from the perspective of outside hosts, for example the server.
It’s not the actual IP address configured on PC1. So, R1 reverses the translation back to PC1’s inside local address, and sends it to PC1.
Now, what if PC2 also wants to communicate over the Internet with 8.8.8.8? Notice that I defined static NAT as being ‘one-to-one’.
On R1 I mapped PC1’s private IP address 192.168.0.167 to the public IP address 100.0.0.1. That’s a one-to-one mapping.
But if PC2 also wants to reach 8.8.8.8, it will need its own IP address. The router would not allow me to map both PC1 and PC2’s IP addresses to 100.0.0.1 using static NAT.
So, in this case I configured R1 to translate PC2’s IP address, 192.168.0.168, to 100.0.0.2.
What’s the name for 192.168.0.168? It’s the inside local address, the actual IP address configured on PC2. And what’s the name for 100.0.0.2?
It’s the inside global address, PC2’s IP address after NAT. Anyway, the server sends the reply to 100.0.0.2, and R1 translates it back to 192.168.0.168 and sends the reply back to PC2.
So, that’s basically how static NAT works. Now, I have to point something out about static NAT. Static NAT allows devices with private IP addresses to communicate over the Internet.
However, because it requires a one-to-one IP address mapping, it doesn’t really help preserve IP addresses. If each internal device needs its own public IP address anyway, you might as well just configure a public IP address on the device itself.
So, although there are reasons to use static NAT, for our purposes it’s not the most useful kind of NAT. Now let’s look at how to configure static NAT, only a few commands are needed.
First, define the inside interface or interfaces by using the IP NAT INSIDE command from interface configuration mode. In this network, R1’s inside interface is G0/1, it’s connected to the internal network.
So I used IP NAT INSIDE on G0/1. Likewise, I used the IP NAT OUTSIDE command on G0/0 to define it as the outside interface. R1 will perform NAT on traffic traveling from the inside interface, G0/1, to the outside interface, G0/0.
Then configure the one-to-one IP address mappings. The command is IP NAT INSIDE SOURCE STATIC, followed by the inside local IP address and then the inside global IP address.
So, I mapped 192.168.0.167 to 100.0.0.1, and 192.168.0.168 to 100.0.0.2.
So, PC1’s IP address will be translated to 100.0.0.1, and PC2’s will be translated to 100.0.0.2. Note that, because these are public IP addresses, to use them you have to actually own them, they must be registered to you or your company.
You can’t just freely use any public IP address you want, like you can with private IP addresses. Finally I used the command SHOW IP NAT TRANSLATIONS.
This is a very useful SHOW command for NAT. Let me point out some important things here. First, when static NAT is used you will see the entries permanently displayed in the translations table.
Personally I think the inside local address should be displayed first on the left and then the inside global, but it’s the opposite. Inside global and then inside local.
So, these two entries are permanent, but then whenever NAT is actually performed on R1, when the addresses are actually translated, dynamic entries for those translations will also appear in this table.
For example, I sent some traffic from PC1 and PC2 to 8.8.8.8, so you can see these two entries. Let’s look at each column, from left to right.
On the left is the ‘Pro’, protocol column, indicating that UDP was used. Then the inside global address column. Notice that next to each IP address there is a colon followed by a number.
What do you think that number is? It’s the port number. For static NAT, you don’t have to pay too much attention to the port numbers, but in day 45 we’ll look at PAT, Port Address Translation, and you’ll see the importance of these port numbers for NAT.
Okay, next is the inside local address column. Notice that, even though the IP addresses have been translated, R1 doesn’t translate the port numbers when using static NAT.
They remain the same. Okay, these last two columns introduce two new terms, outside local and outside global. Let me explain those.
So, you already know about the ‘inside local’ and ‘inside global’ addresses. The ‘outside local’ address is the IP address of the outside host from the perspective of the local network.
So, for example from PC1’s perspective, the server’s IP address is 8.8.8.8, so that’s the outside local IP address. And the ‘outside global’ address is the IP address of the outside host from the perspective of the outside network, the outside hosts.
In this case, the server’s actual IP address is 8.8.8.8, so as you can see both of these are the same, the outside local address and the outside global address.
Unless destination NAT is used, these two addresses will always be the same. Destination NAT is beyond the scope of the CCNA exam, so for our purpose you can expect these two to always be the same.
By the way, notice that the port number is also indicated for these, and they’re using port 53. So, what service did PC1 and PC2 use to access the server?
They used DNS, which uses UDP port 53, and sometimes TCP port 53. So, these four terms, inside local, inside global, outside local, and outside global, can be a little confusing, but make sure you understand the difference.
‘Inside’ and ‘outside’ indicate the location of the host, on the inside network or the outside network. PC1 and PC2 are ‘inside’, and the server at 8.8.8.8 is ‘outside’.
Local and global, on the other hand, indicate the perspective. ‘Local’ means from the perspective of the local, inside network. ‘Global’ means from the perspective of the global, outside network.
So, 192.168.0.167 is PC1’s IP address from the perspective of the local network, and 100.0.0.1 is PC1’s IP address from the perspective of the global network.
If you have any questions about these terms, feel free to ask in the comment section. Let me show a few more useful commands. First, you can clear all of the dynamic translations in the NAT translation table with CLEAR IP NAT TRANSLATION, and then an asterisk.
Even though I only configured static NAT, not dynamic NAT, each time the static NAT entries are actually used, dynamic entries are added to the NAT translation table for those translations.
When PC1 and PC2 stop communicating with 8.8.8.8, these dynamic entries will eventually time out and be removed from the NAT translation table, but this command allows you to manually clear the table.
Notice that, after using that command the two dynamic entries are gone, but the static entries remain. These static NAT entries won’t time out and can’t be deleted unless you remove the IP NAT INSIDE SOURCE STATIC commands from the router.
The last command I want to show you today is this, SHOW IP NAT STATISTICS. Let’s walk through the first few lines of the output. Total active translations 2, and both of them are static.
Since I just cleared the dynamic entries, there aren’t any at the moment. As for extended entries, I’ll explain them in day 45. Peak translations is 4, that’s the highest number of translations that have been in R1’s NAT table.
Here you can see the outside interface, g0/0, and the inside interface, g0/1. So, here are the new commands from this video.
If you don’t remember any of these commands, make sure to go back in the video to review. Also, I recommend practicing these configurations either by making your own labs in packet tracer, or by trying my practice labs.
The static NAT lab will be in the next video. Okay, before the quiz let’s review what we studied today. First I introduced private IPv4 addresses.
Make sure you know those three private IP address ranges, 10.0.0.0/8, 172.16.0.0/12, and 192.168.0.0/16.
Then I gave an introduction to NAT in general. NAT allows routers to modify the source and/or destination addresses of packets.
But for the CCNA, you just need to learn source NAT. Then we looked at one type of source NAT, static source NAT, which involves manually configuring one-to-one mappings of private IP addresses to global IP addresses.
Finally, we looked at how to configure static NAT. Static NAT configuration is fairly simple. Just specify the inside and outside interfaces, and then configure the IP address mappings.
I think that the bigger challenge of this video is understanding those four terms: inside local, inside global, outside local, and outside global. But we’ll cover NAT again in the next video, so if some things are unclear, don’t worry about it.
Also, at the end of the quiz there will be a bonus question from Boson Software’s ExSim for CCNA, so make sure to watch until the end. Okay, let’s go to quiz question 1.
Which of the following commands will configure a static source NAT mapping of 192.168.10.10 to 203.0.113.10? Pause the video now to check the options and select the best answer.
Okay, the answer is D, IP NAT INSIDE SOURCE STATIC, followed by the inside local address which is usually a private address, and then the inside global address, which is usually a public address.
This will map 192.168.10.10 to 203.0.113.10. Okay, let’s go to question 2.
You have configured the following command on R1, IP NAT INSIDE SOURCE STATIC 10.0.0.1 20.0.0.1. What will happen when you issue the following command on R1?
IP NAT INSIDE SOURCE STATIC 10.0.0.2 20.0.0.1. Pause the video now to select the best answer.
Okay, the answer is B, only 10.0.0.1 will be translated to 20.0.0.1. Why is that? I briefly mentioned earlier in the video that, if you have already statically mapped a private IP address to a public IP address, if you try to map another private IP to
that same public IP, the command will be rejected. Here’s what that looks like. The second command is rejected, so only 10.0.0.1 will be translated to 20.0.0.1.
If you want to configure static NAT for 10.0.0.2, you’ll need to use a different public IP address. Okay, let’s go to question 3.
Examine the following partial SHOW command output on R1. How many active translations will there be if you issue the CLEAR IP NAT TRANSLATION (asterisk) command on R1?
Pause the video now to select the correct answer. Okay the answer is B, 3. CLEAR IP NAT TRANSLATION will clear only the dynamic translations, not the 3 static translations.
So, even after issuing the command, 3 translations will remain. Okay, let’s go to question 4. Which of the following are private IPv4 addresses?
(select all that apply). Pause the video now to select all of the correct answers.
Okay, the correct answers are A, 10.254.255.0, E, 172.20.2.3, and F, 10.11.12.13.
Those are the only three addresses that fall within the private IPv4 address ranges as specified in RFC 1918. 10.0.0.0/8, 172.16.0.0/12, and 192.168.0.0/16.
Okay, let’s go to question 5. Examine the packet flow below as PC1 pings 8.8.8.8 and receives a reply.
Identify each of the following addresses in this situation from R1’s perspective. So, identify the outside global, outside local, inside local, and inside global addresses.
If you were to use the command SHOW IP NAT TRANSLATIONS on R1, which address would appear in each column? Pause the video now to think about the answers.
Okay let’s check. The outside global and outside local addresses are both 8.8.8.8. These will only be different if destination NAT is used, and that’s outside of the scope of the CCNA.
The inside local address is 172.20.0.101. That’s the IP address of the inside host, PC1, from the perspective of the inside network.
And the inside global address is 200.0.0.1. That’s the IP address of the inside host, PC1, from the perspective of the outside network.
Once again, make sure you know these different terms well. If you’re confused, go back in the video to review, try a Google search on the topic, and of course feel free to ask questions in the comment section.
Okay, that’s all for the quiz. Next let’s take a look at a bonus question in Boson Software’s ExSim for CCNA. Okay here's today's Boson ExSim practice question.
You issue the SHOW IP NAT TRANSLATIONS command on RouterA and receive the following partial output. So there are 2 entries in RouterA's NAT translation table.
HostA establishes a TFTP connection with HostB. What is the IP address of HostA? Select the best answer. So, these are the six options to choose from.
Pause the video now to select the best answer. Okay let's check.
So, I believe the correct answer is 10.20.30.55. Now how did I decide that? Well, it is a TFTP connection from HostA to HostB.
So how do we know which one is the TFTP connection, which of these entries? We can look at the protocol. TFTP uses UDP, not TCP.
And TFTP's destination port is 69, not 23. So we know it is this top entry. Now how do we know which of these addresses is HostA's address?
So the question isn't 100% clear. It says what is the IP address of HostA? It doesn't say inside global or inside local, so which one is HostA's address?
Well if you get a question like this, it's safe to assume that it's asking about the actual IP address of HostA. Not the NAT address configured on RouterA.
So it's not the inside global address, which is HostA's IP address after NAT. It's asking for the inside local address.
HostA's IP address before NAT, the actual IP address configured on HostA. So that's why I think 10.20.30.55 is the correct answer.
So I will click on show answer. And yes that is correct. So here is Boson's explanation. I highly recommend reading this explanation, so pause the video now to do that.
And there's some more down here at the bottom, as well as some links to Cisco documentation.
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 Pavel, Abraham, Serge, Njoku, Viktor, Roger, Raj, Kenneth, Seamus, H W, Brandon, Samil, Aaron, Marcel, Kone, Donald, C Mohd, Gustavo,
Anthony, Junhong, Benjamin, Tshepiso, 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 18th 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.