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 |
|
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 |
|
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
|
Criteria for Hosts to NAT: |
Inside Local |
Inside Global |
||||
|
10.1.1.0 - 10.1.1.255 v |
Continue reading here: Aggregatable Global Unicast Addresses Was this article helpful? |