This content covers how to configure Network Address Translation (NAT) and Port Address Translation (PAT) on a Cisco router, including creating NAT pools, access lists, and interface assignments. Verification commands such as show ip nat translations and clear ip nat translation are also demonstrated.
NAT & PAT Configuration
This is my network, and this time let's go ahead and set up router 2 to be the translation device. What we're going to do is translate traffic from this network right here — this is going to be the inside network — but we're just going to translate the traffic from the 10.2.0.0 network, and we're going to translate it to everything on this side of the network. So let's see what the commands look like on router 2.
To see if it's working, I'm going to generate traffic from this switch and it's going to go to the demo laptop, and we're going to test to see if it's working by using Wireshark. Here's Wireshark, and it's seeing the different frames coming into it. Let's go ahead and generate a ping from the switch and see what happens. I'm going to pull up that switch and generate some traffic, and there you can see it immediately pops up, and you can see it's coming from 10.2.0.5. So the traffic is going back and forth and it's coming from the address we would expect it to, which is the IP address of that switch.
Now let's do the NAT translation. What I'm going to do is jump on router 2, and I've got to get into the global configuration mode.
The first thing I'm going to do is create a pool. The pool name is Andy — I just came up with this as the name, so you can see that it's whatever we want to name it, so I called it Andy. You start out with the beginning address, so I'm going to use 10.240.2.3. That's the network that — let me pull up my diagram here — that's this interface on this side right there. So I'm going to specify three addresses: 10.240.2.3, .4 and .5. This specifies the last address, so it's a range from this address to this address. I've got to specify the network mask, so here's the network mask right here.
Let's get that onto our router first. This is the pool, so I'm going to copy that and paste it into here.
The next thing that I'm going to do is this access list right here. We haven't got into access lists, but we are defining the access list. We give it a number, so this is number 1. We'll just use the word permit — there's a permit and a deny, but for this purpose we'll just use permit. And we are going to do everything from that last site, so 10.2.0.0, that's the server site. Then we give it a wildcard mask, which is 0.0.255.255, meaning any host in this network. This is the network bits and this is the host bits.
So let's go ahead and get that access list entered in there. I'm going to paste it into here, and there we go.
The next thing that I'm going to do is the ip nat statement. This is the thing that we've already been going over, that we should be somewhat familiar with. It starts out with ip nat inside source, and then the source is list 1. That's referencing this, that's the inside addresses or the local addresses. And then it's going to pool Andy, so these are the global addresses. So we have the local addresses and the global addresses. I'm going to copy that and we'll paste that into here.
Then I'm going to get into the interfaces. So s0000 would be — let me pull up this diagram again — this interface right here, that's the inside, so that's what I'm translating from. And I'm going to the outside, so that's what I'm translating to. I'm going to copy this and put that in there, and then I'm also going to copy this and paste that into there. I get a few errors — that's expected, it's just because of the amount of resources on this device, which is unfortunate.
Now let's generate our traffic again and see what address it's coming from. I'm going to generate that traffic, and we see that now it's coming from 10.240.2.3. That is in the range, so we have now successfully translated: traffic from this switch right here is going to this router, being translated at the router, and then being sent into this network right here. So we are good to go there.
There are a few commands we can use to see what's happening here. I'm going to do a show ip nat translation, and I do need to get into the privileged exec mode, so now I can do show ip nat translation and hit enter. Not surprisingly, there's the entry right there, the entry for that machine, and we've got ICMP, so that all makes sense with what we've seen before.
I'm going to do a show ip nat translation verbose, and this just gives us a little more information on that.
I can do clear ip nat translation. We've seen this before, but I'm just going to do a question mark so we can see what else we have — and I do need to type it in right, translation, so question mark. We can clear all dynamic translations, or we can choose specific TCP or UDP, or inside or outside. So there are a few selections that we have here that we could actually enter into this. And if I wanted to do everything, then I could do these stars, so we're going to delete everything, and that kind of resets that. So those are just some commands that I can use.
The last thing that I'm going to do: at this point in time it's a network address translation, so if I generated any more traffic from that network, it would take up the next address in the range. So rather than 10.240.2.3, the next one would be 10.240.2.4, so it would take up that.
But let's say I want to do PAT, the port address translation. That would stretch this out from just being able to have three devices from that network be translated, to having tons of devices being able to be translated. The only thing we need to do is the same set of commands here, except we add overload to the end of it. So I'm going to copy this — we have to be in the global configuration mode for it — and enter that in, and now at this point in time it will do the port address translation. So it's all the same commands, except it's just this last overload on it that turns it into a port address translation instead of a network address translation.
TechKnowSurge builds IT and cybersecurity professionals through hands-on, concept-first training built around real understanding — not memorization. Free interactive tools, structured programs, and 25+ years of real-world experience, all in one place.
Explore free tools and programs →