Network Address Translation

NAT, defined in RFC 1631, allows a host that does not have a valid registered IP address to communicate with other hosts on the Internet. NAT has gained such wide-spread acceptance that the majority of enterprise IP networks today use private IP addresses for most hosts on the network and use a small block of public IP addresses, with NAT translating between the two.

NAT translates, or changes, one or both IP addresses inside a packet as it passes through a router. (Many firewalls also perform NAT; for the CCIE Routing and Switching exam, you do not need to know NAT implementation details on firewalls.) In most cases, NAT changes the (typically private range) addresses used inside an enterprise network into address from the public IP address space. For instance, Figure 4-6 shows static NAT in operation; the enterprise has registered class C network 200.1.1.0/24, and uses private class A network 10.0.0.0/8 for the hosts inside its network.

Figure 4-6 Basic NAT Concept

e0/0

Server

Outside

Inside Local

Inside Global

10.1.1.1 10.1.1.2

200.1.1.1 200.1.1.2

Beginning with the packets sent from a PC on the left to the server on the right, the private IP source address 10.1.1.1 is translated to a public IP address of 200.1.1.1. The client sends a packet with source address 10.1.1.1, but the NAT router changes the source to 200.1.1.1—a registered public IP address. Once the server receives a packet with source IP address 200.1.1.1, the server thinks it is talking to host 200.1.1.1, so it replies with a packet sent to destination 200.1.1.1. The NAT router then translates the destination address (200.1.1.1) back to 10.1.1.1.

Figure 4-6 provides a good backdrop for the introduction of a couple of key terms, Inside Local and Inside Global. Both terms take the perspective of the owner of the enterprise network. In Figure 4-6, address 10.1.1.1 is the Inside Local address, and 200.1.1.1 is the Inside Global address. Both addresses represent the client PC on the left, which is inside the enterprise network. Address 10.1.1.1 is from the enterprise's IP address space, which is only locally routable inside the enterprise—hence the term Inside Local. Address 200.1.1.1 represents the local host, but the address is from the globally routable public IP address space—hence the name Inside Global. Table 4-13 lists and describes the four main NAT address terms.

Table 4-13 NAT Terminology

KEY POINT

Table 4-13 NAT Terminology

Name

Location of Host Represented by Address

IP Address Space in Which Address Exists

Inside Local address

Inside the enterprise network

Part of the enterprise IP address space; typically a private IP address

Inside Global address

Inside the enterprise network

Part of the public IP address space

Table 4-13 NAT Terminology (Continued)

Name

Location of Host Represented by Address

IP Address Space in Which Address Exists

Outside Local address

In the public Internet; or, outside the enterprise network

Part of the enterprise IP address space; typically a private IP address

Outside Global address

In the public Internet; or, outside the enterprise network

Part of the public IP address space

Static NAT

Static NAT works just like the example in Figure 4-6, but with the IP addresses statically mapped to each other via configuration commands. With static NAT:

■ A particular Inside Local address always maps to the same Inside Global (public) IP address.

■ If used, each Outside Local address always maps to the same Outside Global (public) IP address.

■ Static NAT does not conserve public IP addresses.

Although static NAT does not help with IP address conservation, static NAT does allow an engineer to make an inside server host available to clients on the Internet, because the inside server will always use the same public IP address.

Example 4-1 shows a basic static NAT configuration based on Figure 4-6. Conceptually, the NAT router has to identify which interfaces are inside (attach to the enterprise's IP address space) or outside (attach to the public IP address space). Also, the mapping between each Inside Local and Inside Global IP address must be made. (Although not needed for this example, outside addresses can also be statically mapped.)

Example 4-1 Static NAT Configuration

KEY POINT

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! E0/0 attaches to the internal Private IP space, so it is configured as an inside interface, interface Ethernet0/0 ip address 10.1.1.3 255.255.255.0 ip nat inside

! S0/0 is attached to the public Internet, so it is defined as an outside ! interface. interface Serial0/0 ip address 200.1.1.251 255.255.255.0 ip nat outside

Example 4-1 Static NAT Configuration (Continued)

! Next, two inside addresses are mapped, with the first address stating the ! Inside Local address, and the next stating the Inside Global address, ip nat inside source static 10.1.1.2 200.1.1.2 ip nat inside source static 10.1.1.1 200.1.1.1

! Below, the NAT table lists the permanent static entries from the configuration. NAT# show ip nat translations

Pro Inside global Inside local Outside local Outside global

--- 200.1.1.1 10.1.1.1 --- ----- 200.1.1.2 10.1.1.2 --- ---

The router is performing NAT only for inside addresses. As a result, the router processes packets entering E0/0—packets that could be sent by inside hosts—by examining the source IP address. Any packets with a source IP address listed in the Inside Local column of the show ip nat translations command output (10.1.1.1 or 10.1.1.2) will be translated to source address 200.1.1.1 or 200.1.1.2, respectively, per the NAT table. Likewise, the router examines the destination IP address of packets entering S0/0, because those packets would be destined for inside hosts. Any such packets with a destination of 200.1.1.1 or .2 will be translated to 10.1.1.1 or .2, respectively.

In cases with static outside addresses being configured, the router also looks at the destination IP address of packets sent from the inside to the outside interfaces, and the source IP address of packets sent from outside interfaces to inside interfaces.

Dynamic NAT Without PAT

Dynamic NAT (without PAT), like static NAT, creates a one-to-one mapping between an Inside Local and Inside Global address. However, unlike static NAT, it does so by defining a set or pool of Inside Local and Inside Global addresses, and dynamically mapping pairs of addresses as needed. For example, Figure 4-7 shows a pool of five Inside Global IP addresses—200.1.1.1 through 200.1.1.5. NAT has also been configured to translate any Inside Local addresses whose address starts with 10.1.1.

The numbers 1, 2, and 3 in Figure 4-7 refer to the following sequence of events:

1. Host 10.1.1.2 starts by sending its first packet to the server at 170.1.1.1.

2. As the packet enters the NAT router, the router applies some matching logic to decide if the packet should have NAT applied. Because the logic has been configured to mean "translate Inside Local addresses that start with 10.1.1," the router dynamically adds an entry in the NAT table for 10.1.1.2 as an Inside Local address.

3. The NAT router needs to allocate a corresponding IP address from the pool of valid Inside Global addresses. It picks the first one available (200.1.1.1 in this case) and adds it to the NAT table to complete the entry.

Figure 4-7 Dynamic NAT

KEY POINT

Inside

NAT Table Before First Packet

Criteria for Hosts to NAT:

Inside Local

Inside Global

10.1.1.0 - 10.1.1.255 v

NAT Table After First Packet

Readers' Questions

  • amna
    What is the group of public ipv4 addresses used on a natenabled router known as?
    7 months ago
  • The group of public IPv4 addresses used on a NAT-enabled router is known as a public IP address pool.
    • anthony
      What is defined by the ip nat pool command when configuring dynamic nat?
      8 months ago
    • The ip nat pool command is used to define a range of source addresses when configuring dynamic network address translation (NAT). It is used to specify the public IP addresses to be allocated to the private IP addresses of internal hosts.
      • halfred
        Which type of nat maps a single inside local address to a single inside global address?
        8 months ago
      • Static NAT (Network Address Translation)
        • emanuela
          When configuring nat on a cisco router, what is the inside local ip address?
          8 months ago
        • The inside local IP address is the IP address of the device located on the inside network before it is translated by the router.

          Inside Local

          Inside Global

          10.1.1.2

          Outside

          Inside

          Outside

          With the completion of step 3, the NAT router can actually translate the source IP address, and forward the packet. Note that as long as the dynamic NAT entry exists in the NAT table, only host 10.1.1.2 can use Inside Global IP address 200.1.1.1.

          Overloading NAT with Port Address Translation

          As mentioned earlier, NAT is one of the key features that helped to reduce the speed at which the IPv4 address space was being depleted. NAT overloading, also known as Port Address Translation (PAT), is the NAT feature that actually provides the significant savings of IP addresses. The key to understanding how PAT works is to consider the following: From a server's perspective, there is no significant difference between 100 different TCP connections, each from a different host, and 100 different TCP connections all from the same host.

          PAT works by making large numbers of TCP or UDP flows from many Inside Local hosts appear to be the same number of large flows from one (or a few) host's Inside Global addresses. With PAT, instead of just translating the IP address, NAT also translates the port numbers as necessary. And because the port number fields are 16 bits in length, each Inside Global IP address can support over 65,000 concurrent TCP and UDP flows. For instance, in a network with 1000 hosts, a single public IP address used as the only Inside Global address could handle an average of six concurrent flows from each host to and from hosts on the Internet.

          Dynamic NAT and PAT Configuration

          Like static NAT, dynamic NAT configuration begins with identifying the inside and outside interfaces. Additionally, the set of Inside Local addresses is configured with the ip nat inside global command. If you are using a pool of public Inside Global addresses, the set of addresses is defined by the ip nat pool command. Example 4-2 shows a dynamic NAT configuration based on the internetwork shown in Figure 4-7. The example defines 256 Inside Local addresses and two Inside Global addresses.

          Example 4-2 Dynamic NAT Configuration

          KEY POINT

          First, the ip nat pool fred command lists a range of IP addresses. The ip nat inside source list 1 pool fred command points to ACL 1 as the list of Inside Local addresses, with a cross-reference to the pool name.

          interface Ethernet0/0 ip address 10.1.1.3 255.255.255.0 ip nat inside

          interface Serial0/0 ip address 200.1.1.251 255.255.255.0 ip nat outside

          ip nat pool fred 200.1.1.1 200.1.1.2 netmask 255.255.255.252

          ip nat inside source list 1 pool fred

          access-list 1 permit 10.1.1.0 0.0.0.255

          ! Next, the NAT table begins as an empty table, because no dynamic entries had

          ! been created at that point.

          NAT# show ip nat translations

          ! The NAT statistics show that no hits or misses have occurred. Hits occur when ! NAT looks for a mapping, and finds one. Misses occur when NAT looks for a NAT ! table entry, does not find one, and then needs to dynamically add one. NAT# show ip nat statistics

          Total active translations: 0 (0 static, 0 dynamic; 0 extended) Outside interfaces:

          Serial0/0 Inside interfaces:

          Ethernet0/0 Hits: 0 Misses: 0 Expired translations: 0 Dynamic mappings: -- Inside Source access-list 1 pool fred refcount 0 pool fred: netmask 255.255.255.252 start 200.1.1.1 end 200.1.1.2

          type generic, total addresses 2, allocated 0 (0%), misses 0 ! At this point, a Telnet session from 10.1.1.1 to 170.1.1.1 started.

          Example 4-2 Dynamic NAT Configuration (Continued)

          ! Below, the 1 "miss" means that the first packet from 10.1.1.2 did not have a ! matching entry in the table, but that packet triggered NAT to add an entry to the ! NAT table. Host 10.1.1.2 has then sent 69 more packets, noted as "hits" because ! there was an entry in the table. NAT# show ip nat statistics

          Total active translations: 1 (0 static, 1 dynamic; 0 extended) Outside interfaces:

          Serial0/0 Inside interfaces:

          Ethernet0/0 Hits: 69 Misses: 1 Expired translations: 0 Dynamic mappings: -- Inside Source access-list 1 pool fred refcount 1 pool fred: netmask 255.255.255.252 start 200.1.1.1 end 200.1.1.2

          type generic, total addresses 2, allocated 1 (50%), misses 0 ! The dynamic NAT entry is now displayed in the table. NAT# show ip nat translations

          Pro Inside global Inside local Outside local Outside global

          ! Below, the configuration uses PAT via the overload parameter. Could have used the ! ip nat inside source list 1 int s0/0 overload command instead, using a single ! IP Inside Global IP address.

          NAT(config)# no ip nat inside source list 1 pool fred NAT(config)# ip nat inside source list 1 pool fred overload

          ! To test, the dynamic NAT entries were cleared after changing the NAT ! configuration. Before the next command was issued, host 10.1.1.1 had created two ! Telnet connections, and host 10.1.1.2 created 1 more TCP connection. NAT# clear ip nat translations *

          ! Before the next command was issued, host 10.1.1.1 had created two ! Telnet connections, and host 10.1.1.2 created 1 more TCP connection. Note that ! all three dynamically mapped flows use common Inside Global 200.1.1.1. NAT# show ip nat translations

          Pro Inside global Inside local Outside local Outside global tcp 200.1.1.1:3212 10.1.1.1:3212 170.1.1.1:23 170.1.1.1:23

          tcp 200.1.1.1:3213 10.1.1.1:3213 170.1.1.1:23 170.1.1.1:23

          tcp 200.1.1.1:38913 10.1.1.2:38913 170.1.1.1:23 170.1.1.1:23

          Continue reading here: Aggregatable Global Unicast Addresses

          Was this article helpful?

          0 0