Intermediate · IP services: DHCP, DNS, NAT and more · topic 38 of 57 · 35 min
NAT and PAT
Explanation
Why NAT exists
IPv4 has about 4.3 billion addresses, far fewer than the devices in the world. The private ranges (10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16) can be used freely inside any organisation, but they are not routed on the internet. NAT, done by the router at the edge, replaces the private source address of outgoing packets with a public one, and reverses the change for the replies. One public address can then serve a whole office.
The four terms
Cisco describes every address in a translation by two words: inside or outside (whose address is it?) and local or global (from which side is it seen?).
| Term | Meaning | Example |
|---|---|---|
| Inside local | The private address of an inside host, as seen inside | 192.168.10.21 |
| Inside global | The public address that represents that inside host on the internet | 203.0.113.2 |
| Outside global | The real address of the outside host | 198.51.100.7 |
| Outside local | The outside host's address as seen from inside; usually the same as outside global | 198.51.100.7 |
Three kinds of NAT
- Static NAT: one private address is permanently mapped to one public address. Used for servers that people outside must reach, such as a web or mail server.
- Dynamic NAT: inside hosts get a public address from a pool, first come first served, one public address per host while it is in use. If the pool runs out, new hosts cannot get out. Rare today.
- PAT (Port Address Translation), also called NAT overload: many inside hosts share ONE public address. The router tells conversations apart by the source port number. This is what every home router and most offices use.
How PAT keeps conversations apart
Every TCP or UDP conversation has a source port. When two laptops both use source port 51000, the router keeps one as 203.0.113.2:51000 and changes the other to, say, 203.0.113.2:1024. Each entry in the NAT table maps (inside address, inside port) to (public address, public port). When a reply arrives for 203.0.113.2:1024, the router looks it up and sends it to the second laptop. One public address has about 65,000 ports per protocol, so in theory tens of thousands of conversations can share it. An office of 200 people with browsers, email and Teams fits easily.
Configuring NAT on a Cisco router
R1(config)# interface GigabitEthernet0/0
R1(config-if)# ip address 192.168.10.1 255.255.255.0
R1(config-if)# ip nat inside
R1(config)# interface GigabitEthernet0/1
R1(config-if)# ip address 203.0.113.2 255.255.255.248
R1(config-if)# ip nat outside
! PAT: every host in 192.168.10.0/24 shares G0/1's address
R1(config)# access-list 1 permit 192.168.10.0 0.0.0.255
R1(config)# ip nat inside source list 1 interface GigabitEthernet0/1 overload
! Static NAT: the web server is always 203.0.113.5 on the internet
R1(config)# ip nat inside source static 192.168.10.50 203.0.113.5For dynamic NAT with a pool, you define the public range and point the rule at it: ip nat pool PUBLIC 203.0.113.3 203.0.113.4 netmask 255.255.255.248, then ip nat inside source list 1 pool PUBLIC. Adding overload to that line turns it into PAT over the pool.
Verifying
R1# show ip nat translations
Pro Inside global Inside local Outside local Outside global
tcp 203.0.113.2:51000 192.168.10.21:51000 198.51.100.7:443 198.51.100.7:443
tcp 203.0.113.2:1024 192.168.10.22:51000 198.51.100.7:443 198.51.100.7:443
--- 203.0.113.5 192.168.10.50 --- ---
R1# show ip nat statistics
R1# clear ip nat translation *CGNAT: NAT at the ISP
Many mobile operators and some broadband ISPs, in India and elsewhere, do not have enough public IPv4 addresses for every customer. They use carrier-grade NAT (CGNAT): your router or phone gets an address from 100.64.0.0/10 (a range reserved for this) or another private range, and the ISP translates again to a shared public address. The effect is double NAT: browsing works, but nobody on the internet can start a connection to you, so port forwarding for a home camera or game server will not work. IPv6 removes the need for NAT because there are enough addresses for every device.
Need help?
Stuck on a word or an idea? Search this course, or every course, and jump straight to the explanation or a worked question.
Try:
Watch the lesson
NAT and PAT · 1/7
In this lesson you will learn how a whole office shares one public IP address using NAT.
Prefer a video by a teacher? Find free videos on “nat pat overload explained ccna inside local inside global packet tracer” on YouTube ↗
In real life: An office of 200 people on one public IP
A chartered accountancy firm in Kolkata has 200 staff on 192.168.0.0/22 and one broadband line with a single public address. The edge router runs PAT with ip nat inside source list 1 interface g0/1 overload. At 11 am, show ip nat translations lists about 3,000 entries: browsers, Outlook, Teams and the GST portal, all leaving from the same public IP with different ports. The firm's document server, reached by clients from outside, has a static NAT entry to a second public address the ISP provided.
Practice (0/3 done)
A PC with address 192.168.10.21 browses a website. The router changes the source to 203.0.113.2. What is 192.168.10.21 called?
Build a small PAT table. Complete the class Pat(public_ip, first_port=1024). translate(inside_ip, inside_port) returns (public_ip, public_port): a NEW conversation gets the next free public port, starting at first_port and counting up; the SAME (inside_ip, inside_port) always gets the port it got before. reverse(public_port) returns the (inside_ip, inside_port) for a reply, or None if unknown. (Real routers try to keep the original port when it is free; this simpler version always picks the next one.)
Packet Tracer lab. LAN 192.168.10.0/24 behind R1 (G0/0 192.168.10.1). R1 G0/1 is 203.0.113.2/29 towards an "ISP" router (G0/1 203.0.113.1/29) that has a loopback 198.51.100.7/32 acting as an internet server. Configure PAT for the LAN on R1 and a static NAT entry so that a LAN web server (192.168.10.50) is reachable as 203.0.113.5. The ISP router must NOT have any route to 192.168.10.0/24.
Quick quiz
Read more (free)
Related help
Before this, learn
This topic builds on these. If something here feels new, open them first.
Related topics
- Management services: NTP, SNMP, syslog and TFTPIP services: DHCP, DNS, NAT and more · same module
- IP addresses, subnets and CIDRCyber Security: from zero to SOC analyst · Networking for security
- VPC basics: CIDR, subnets and gatewaysCloud Computing (AWS, Azure, Google Cloud) · Networking and databases: VPC and RDS
- Network devicesHow networks work
- Network basics: IP addresses, routes, DNS and the ip commandLinux and Red Hat (RHCSA to RHCE) · Software and networking
- Virtualisation, VRFs and cloud networkingAutomation, SDN and cloud networking
Questions people ask about this
Open a question to see the answer and why. The first ones are this topic's own quiz, so try the quiz above before you peek.
Which type of NAT lets hundreds of inside hosts share one public IP address?
Answer: PAT (NAT overload)
PAT uses port numbers to keep many conversations apart on one address.
Which command creates a permanent one-to-one mapping for a server?
Answer: ip nat inside source static 192.168.10.50 203.0.113.5
ip nat inside source static maps one inside local address to one inside global address permanently.
PAT is configured, but no translations appear and PCs cannot reach the internet. show run shows "ip nat outside" on the LAN interface and "ip nat inside" on the WAN. What is wrong?
Answer: Inside and outside are swapped
The LAN interface must be ip nat inside and the WAN interface ip nat outside.
Your home router's WAN address is 100.72.14.9. What does this suggest?
Answer: Your ISP uses carrier-grade NAT
100.64.0.0/10 is the shared address space used for CGNAT, so you are behind your ISP's NAT.
Which command removes all dynamic NAT translations?
Answer: clear ip nat translation *
clear ip nat translation * clears the dynamic entries; static entries stay.
Why do private addresses and NAT exist?Related
Answer: Because there are not enough public IPv4 addresses for every device
IPv4 has about 4.3 billion addresses, fewer than the number of devices. Private ranges are reused everywhere and NAT shares a few public addresses.
Which address is private?Related
Answer: 172.20.1.5
172.16.0.0/12 covers 172.16.x.x to 172.31.x.x, so 172.20.1.5 is private; 172.32.1.5 is not.
An app server in a private subnet must download OS updates but must not accept connections from the internet. What does its route table need?Related
Answer: 0.0.0.0/0 to a NAT gateway
A NAT gateway allows outbound connections from private subnets while blocking inbound ones.
Where do you configure ip helper-address?Related
Answer: On the router interface facing the DHCP clients
The relay must be on the interface that receives the clients' broadcasts, which is their default gateway.
Pass the quiz (60% or more) or mark this topic as done when you are ready.
Your progress is saved on this device only.
Next steps
- 2 more topics in “IP services: DHCP, DNS, NAT and more” before its exam: Management services: NTP, SNMP, syslog and TFTP, QoS basics: keeping voice and video clear.
- Module 8 exam: IP services · 15 questions · 25 min, without help. 5 topics of this module still to finish first.
- Then the next module, Network security. 57 topics left in the course before the final exam.