Network Address Translation (NAT)
Private IPv4 Addresses (RFC 1918)
- Concept: IPv4 address exhaustion led to the reservation of specific IP ranges for internal/private networks. These addresses are not globally unique and cannot be routed over the public Internet.
- RFC 1918 Ranges:
- Class A:
10.0.0.0/8(10.0.0.0 – 10.255.255.255) - Class B:
172.16.0.0/12(172.16.0.0 – 172.31.255.255) - Class C:
192.168.0.0/16(192.168.0.0 – 192.168.255.255)
- Class A:
- Note: You can subnet these ranges however you want using CIDR. ISPs will drop traffic originating from or destined to these addresses on the public Internet.
NAT Terminology
Understanding the four NAT address types is critical for the CCNA.
- Inside vs. Outside: Refers to the location of the host (Internal network vs. External/Internet).
- Local vs. Global: Refers to the perspective of the packet (Actual configured IP vs. IP seen by the other network).
| Term | Definition | Typical Address Type |
|---|---|---|
| Inside Local | The actual IP address configured on the internal host. | Private IP |
| Inside Global | The IP address of the internal host after NAT translation, as seen by the outside world. | Public IP |
| Outside Local | The IP address of the external host as seen from the inside network. | Usually same as Outside Global |
| Outside Global | The actual IP address configured on the external host. | Public IP |
graph LR
subgraph Inside Network
A[PC1: 192.168.1.10] -- Inside Local --> R[NAT Router]
end
subgraph Internet
R -- Inside Global --> B[203.0.113.5]
B -- Outside Global --> C[Server: 8.8.8.8]
C -- Outside Local --> R
end
Static NAT
- Concept: Manually configures a permanent one-to-one mapping between an Inside Local address and an Inside Global address.
- Inbound Traffic: Because the mapping is permanent, external hosts can initiate connections to the internal host using the Inside Global IP.
- Limitation: Does not conserve public IP addresses (requires 1 public IP per internal device).
! 1. Define Inside and Outside interfaces
R1(config)# interface GigabitEthernet0/1
R1(config-if)# ip nat inside
R1(config-if)# exit
R1(config)# interface GigabitEthernet0/0
R1(config-if)# ip nat outside
R1(config-if)# exit
! 2. Configure 1-to-1 Static Mapping
! Syntax: ip nat inside source static <local> <global>
R1(config)# ip nat inside source static 192.168.1.10 203.0.113.10
Dynamic NAT
- Concept: Dynamically maps Inside Local addresses to Inside Global addresses from a predefined NAT Pool.
- Mapping: Still a one-to-one mapping at any given time, but mappings are temporary and assigned on a first-come, first-served basis.
- Traffic Identification: Uses an ACL to identify which traffic should be translated.
- Crucial Exam Tip: If a packet is denied by the NAT ACL, it is NOT translated, but it is NOT dropped by the router (unless dropped by a separate interface ACL).
- NAT Pool Exhaustion: If all IPs in the pool are in use and a new host requires NAT, the router will drop the packet.
- Timers: Dynamic mappings default to a 24-hour timeout (resets each time a translation is made).
! 1. Define interfaces (ip nat inside / outside)
! 2. Create ACL to identify traffic to be translated (Uses Wildcard Mask!)
R1(config)# access-list 1 permit 192.168.1.0 0.0.0.255
! 3. Define the NAT Pool (Uses Prefix-Length or Netmask!)
R1(config)# ip nat pool POOL1 203.0.113.10 203.0.113.20 prefix-length 24
! 4. Bind ACL to Pool
! Syntax: ip nat inside source list <acl> pool <pool>
R1(config)# ip nat inside source list 1 pool POOL1
Port Address Translation (PAT) / NAT Overload
- Concept: Maps many Inside Local addresses to a single (or few) Inside Global addresses by translating both the IP address and the Layer 4 Port number.
- Purpose: Highly conserves public IPv4 addresses. This is the most widely used NAT type in the real world (e.g., home routers).
- Flow Tracking: The router tracks communication flows using unique source port numbers. If two internal hosts use the same source port, the router will change one of them to ensure uniqueness.
Configuration Method 1: Using a NAT Pool
! 1. Define interfaces
! 2. Create ACL
R1(config)# access-list 1 permit 192.168.1.0 0.0.0.255
! 3. Define Pool
R1(config)# ip nat pool POOL1 203.0.113.10 203.0.113.10 prefix-length 24
! 4. Bind with OVERLOAD keyword
R1(config)# ip nat inside source list 1 pool POOL1 overload
Configuration Method 2: Using the Router’s Interface IP (Most Common)
! 1. Define interfaces
! 2. Create ACL
R1(config)# access-list 1 permit 192.168.1.0 0.0.0.255
! 3. Bind to Interface with OVERLOAD keyword
! Syntax: ip nat inside source list <acl> interface <int> overload
R1(config)# ip nat inside source list 1 interface GigabitEthernet0/0 overload
NAT Verification and Troubleshooting
Use these commands to verify NAT operation and clear stale entries.
! View the NAT translation table
! Note: Output displays Inside Global BEFORE Inside Local
R1# show ip nat translations
Pro Inside global Inside local Outside local Outside global
icmp 203.0.113.1:512 192.168.1.10:512 8.8.8.8:512 8.8.8.8:512
! View NAT statistics, pool usage, and active translation counts
R1# show ip nat statistics
! Clear DYNAMIC translations only (Static translations remain intact)
R1# clear ip nat translation *
! Clear a specific dynamic translation
R1# clear ip nat translation protocol inside global-ip local-ip outside global-ip outside local-ip
Comparison of NAT Types
| Feature | Static NAT | Dynamic NAT | Dynamic PAT (NAT Overload) |
|---|---|---|---|
| Mapping Type | One-to-One (Permanent) | One-to-One (Temporary) | Many-to-One (Temporary) |
| Configuration | Manual IP mapping | ACL + NAT Pool | ACL + Pool OR Interface + overload |
| Port Translation | No | No | Yes (Translates IP & Port) |
| Inbound Traffic? | Yes (Outside can initiate) | No (Only if mapping exists) | No (Only if port mapping exists) |
| Pool Exhaustion | N/A | Drops packet | N/A (Uses ports to scale) |
| IP Conservation | Poor | Moderate | Excellent |
Important Exam Tips & Misconceptions
- ACLs in NAT do NOT drop traffic: When configuring Dynamic NAT/PAT, the ACL is used only to match traffic for translation. If a packet matches a
denystatement in the NAT ACL, the router simply forwards it without translating the IP. clear ip nat translation *behavior: This command only clears dynamic translations. Statically configured NAT mappings will remain in the table.- Static NAT Uniqueness: You cannot map two different Inside Local IPs to the same Inside Global IP using Static NAT. The router will reject the second command.
- Subnet vs. Wildcard Masks:
- When defining an ACL for NAT, use a Wildcard Mask (e.g.,
0.0.0.255). - When defining a NAT Pool, use a Prefix-Length or Subnet Mask (e.g.,
prefix-length 24ornetmask 255.255.255.0). The router checks that the start and end IPs fall within this exact subnet.
- When defining an ACL for NAT, use a Wildcard Mask (e.g.,
- Boson ExSim Insight (TFTP): If a question asks to identify a TFTP flow in
show ip nat translations, look for UDP and destination port 69 (Not TCP, and not port 23 which is Telnet). The “Inside Local” address is the actual IP of the internal host.
Command Summary
! --- Interface Configuration ---
Router(config-if)# ip nat inside
Router(config-if)# ip nat outside
! --- Static NAT ---
Router(config)# ip nat inside source static <local-ip> <global-ip>
! --- Dynamic NAT & PAT ---
Router(config)# access-list <1-99> permit <subnet> <wildcard>
Router(config)# ip nat pool <name> <start-ip> <end-ip> prefix-length <len>
Router(config)# ip nat inside source list <acl> pool <pool>
Router(config)# ip nat inside source list <acl> pool <pool> overload
Router(config)# ip nat inside source list <acl> interface <type/num> overload
! --- Verification & Maintenance ---
Router# show ip nat translations
Router# show ip nat statistics
Router# clear ip nat translation *