White Paper

How to PDF Get Acrobat Reader

Network Address Translation (NAT)

By Clark Milner (cmilner@cisco.com)

Network-to-User Business Unit Product Marketing Engineer



Table of Contents

Network Address Translation (NAT)

Abstract

With the proliferation of TCP/IP throughout the world, a shortage of IP addresses is becoming a problem. Various techniques are being introduced that help maximize the utilization of assigned Internet Assigned Numbers Authority (IANA) addresses, and Cisco Systems has introduced one such technique, called Network Address Translation (NAT). This paper discusses the various methodologies and configurations of NAT, along with the ramifications of this address conservation tool.

Introduction

The Internet Assigned Numbers Authority (IANA) is currently faced with the dilemma of the proliferation of
TCP/IP throughout the Internet, a situation that poses the compelling problem of IP address depletion and scalable routing of the existing and future addressing schemes. Enterprise-wide intranets, which originally are intended for intraenterprise communication only, but later require access to the Internet as well, further compound the dilemma. And, finally, the growth explosion of Internet service providers (ISPs) continually taxes the IANA for addressing schemes and networking companies for routing schemes.

The term intranet is defined for this document as a collection of networks interconnected by routers and other devices that function generally as a single network, to comprise the enterprise. The term Internet refers to the largest global network that connects tens of thousands of these enterprise intranets together, so that intranets can communicate with each other. The intranet is internal and controllable by the enterprise, while the Internet is external and out of the control of the enterprise.

The current growth rate of both the Internet and intranets demands that addressing no longer be defined by globally unique addressing schemes. This scenario allows intranets to be part of the Internet without the current renumbering of entire intranet addresses.

Host systems can be classified into three realms:

Intrahost systems require access to other host systems within the intranet scope only. They do not require access to other intranets, nor to the Internet itself. These systems can use unambiguous IP addressing schemes, as long as the scheme remains consistent throughout the intranet itself.

Intra-/interhost systems primarily reside and function within the intranet itself, but they also require access to other intranets, and to other (albeit limited) Internet systems and resources. Again, these systems can use unambiguous addressing schemes, but they require special routing schemes to use them. The schemes here can be unambiguous within the principal intranet, but must be ambiguous between intranets and the Internet.

Finally, interhost systems require complete and unrestricted access to other intranets, and the Internet itself. These systems must follow strict addressing schemes globally.

Recognizing these classifications of host systems, the IANA responded with an intranet addressing scheme. A block of addresses were globally set aside from the public addressing pool for private, enterprise-wide usage. They are given in Table 1.


Table 1  : IANA-Allocated, Non-Internet Routable, IP Address Schemes
Address Class Range Network Address Range
A 10.0.0.0-10.255.255.255
B 172.16.0.0-172.31.255.255
C 192.168.0.0-192.168.255.255

The addressing schemes in Table 1 were also deemed nonroutable throughout the Internet, meaning that ISPs must filter on and block the routing of packets to and from these networks. Although such filtering is ideal for the first class of host systems, it is not easy to implement in the other two types of host systems because they require Internet routing capabilities. Thus, if the enterprise follows this scheme initially for defining its intranet, when it requires reclassifying hosts into the other two classes it also requires a renumbering and implementation of a new address scheme, or some sort of advanced routing scheme.

One such routing scheme that supports connectivity using globally/nonunique addressing schemes is Network Address Translation (NAT). Supporting all the discussed host system classifications, NAT can be effectively used to reduce the number of IANA-assigned address classes. NAT allows the reuse of routable address classes by translating nonroutable intranet address schemes into routable, globally unique address schemes. This mechanism provides for privately addressed networks to access other IANA-registered networks, without requiring a registration of the private intranet subnet addressing. This setup eliminates the need for renumbering current address schemes to support Internet host system requirements. With NAT, the private intranet is defined as "inside" address schemes, and it allows the continued use of existing private or obsolete addressing schemes. NAT converts these inside addressing schemes into legally registered addressing, prior to forwarding the packets to the public Internet, defined as "outside." The NAT router is defined as the boundary point for defining inside and outside addressing schemes. The translation is fully compatible with standard routing functionality and features, and NAT needs to be applied only on the router that is connected physically to both inside and outside addressing schemes.

NAT is valuable for its ability to perform the translation; in addition, NAT simplifies network administration by supporting less-stringent requirements on addressing schemes. NAT's role as an application-layer border router simplifies operations, is fully transparent to the end host system, is fully flexible in support of various applications and protocols, and leads to better system performance.

NAT is fully supported as of Cisco IOSTM software Release 11.2. It is supported on the following hardware platforms:

Another platform that supports a subset of NAT, called Port Address Translation (PAT), is:

For feature-specific releases, verify the inclusion of NAT-specific support. In other words, you need a Cisco IOS Release 11.2 or newer, and a version of Cisco IOS software from the "s" feature set.

Defining Network Address Translation (NAT)

In the most basic explanation, NAT is a feature that operates on a border router between an inside private addressing scheme and an outside public addressing scheme. The translation functions in conjunction with the other routing features, allowing for transparent access to the Internet from privatized remote hosts. The IANA address reuse solution simply pairs up inside addresses to outside addresses. Therefore, the inside address appears to the outside as an outside, legally registered address.

This solution was originally intended for a very small number of inside hosts communicating with outside hosts, but it is fully scalable and desirable for ISPs, who require large inside networking schemes. It is the ISPs who can benefit the most from this solution; it saves them the expensive costs of registering large numbers of address classes.

NAT eliminates the end-to-end significance of IP addressing, to allow for increased addressing scheme reuse. TCP, a connection-oriented protocol, is essentially doing address reuse at every hop; NAT just extends this reuse to the network layer.

NAT is a router function configured on inside/outside boundaries, as shown in Figure 1. NAT must be configured on every boundary router, and even more importantly, the translation table that maps inside IP to outside IP must be identical on each boundary router.


Figure 1: NAT Router Boundary Definition with Internal Translation Network Address Pool

NAT is interface independent, meaning that NAT can be applied to any interface on the router that links inside to outside addressing schemes. In Figure 1, the host system is using a privatized IP address of 10.2.2.1 as part of the intranet. When the packet reaches the router, NAT translates the 10.2.2.1 address into another address from the NAT IP pool allocated, say 171.69.89.2. Thus it is as if that machine is virtually moved to the outside network segment for outside communication purposes. The network segment 171.69.89.0 resides within the NAT router box itself for this example, but can be part of the network connecting the boarder router to the global network. This setup can be seen om Figure 2.


Figure 2: NAT Router Boundary Definition with External Translation Network Address Pool

In both these cases, the NAT IP pool is considered as part of the outside addressing scheme, and not as part of the inside addressing scheme, even though in the first case, the pool is internal to the intranet's boarder router. NAT IP pool definition must follow the unique addressing public scheme; thus the pool allocations must not contain overlaps with the outside global addressing scheme, and only a one-to-one translation can be defined. (The exception to this is PAT, which is discussed later.) The NAT translation is a two-way process; thus any packet reaching the NAT router from the outside is translated to the NAT table-equivalent inside address, if such a mapping exists.

NAT Routing

When NAT is implemented, the inside addressing scheme should never be advertised to the outside, but the reverse is desirable. All outside address schemes should be advertised to the inside. In this way, the inside host systems are considered as hidden extensions of the Internet. If, for example, the inside addresses are advertised to the outside, and another similar addressing scheme exists elsewhere, then Internet routers would be confused and would not reliably transmit packets to both networks with the same addressing schemes. Alternatively, if the outside schemes are not advertised internally, then the host systems do not know where to route the packets, except to the defined default route, which may or may not lead to the outside.

To solve this problem, a distribution list for the routing process can be implied. This step blocks the outside from seeing inside network addresses, yet otherwise allows full routing to occur. As an example, in the following configuration the inside NAT networks are denied distribution in the routing process for outside networks:


router eigrp n

 network "outside network address"

 distribute-list 3 out

 distribute-list 3 in

 no auto-summary

# access-list 3 to deny inside network addresses

access-list 3 deny 192.168.0.0 0.0.255.255

access-list 3 permit any

How NAT Works

Since NAT performs a one-to-one IP mapping, the packet that enters the NAT router, from the inside destined to the outside and vice versa, undergoes a transformation. In its simplest form, the IP address in the header files are translated and replaced with the new inside or outside IP address scheme. In addition to changing the IP address in the IP header, the checksum for the IP packet must be recalculated and verified for integrity. Also, because the TCP header contains a checksum that is calculated by analyzing the socket, which is a combination of the TCP port address and the IP address, the TCP header must be modified as well. To make the NAT transparent to the application layers, the NAT process must also convert any application packet that contains reference to the address scheme that is being translated, to reference the new addressing scheme.

NAT and FTP

For File Transfer Protocol (FTP), both the PORT command and the PASV commands contain a reference to the IP address scheme, albeit in ASCII, but these must be translated as well. The translator monitors the control stream and replaces these instances with the proper ASCII IP addresses. This replacement may cause a change in packet size, and thus require the TCP checksum to be recalculated to verify integrity. If the new file size is less then the previous one, then the packet is stuffed by filling it with zeros to maintain the original packet size. If the packet becomes larger than the original packet size, the sequence numbering requires adjusting as well. A special table is then used to ensure correct translation of ACKnowledgment and SEQuence numbering. This table ensures correct ACK, SEQ number correlation to source and destination port references.

NAT and ICMP

Internet Control Message Protocol (ICMP) packets contain embedded IP headers that must be translated, along with the embedded IP checksum. Of course the Internet Control Message Protocol (ICMP) checksum must be recalculated as well. The IP header itself, which encapsulates the ICMP packet, must be modified, as already discussed. The following ICMP packets are modified by NAT:

NAT and SNMP

Simple Network Management Protocol (SNMP) packets that contain the source or destination must be translated, as well as any SNMP packet that has the domain name qualified by a physical address, and not as domain name.

NAT and SMTP

A valid Simple Mail Transfer Protocol (SMTP) address can contain an IP address rather then a domain name, and thus must be translated, if required.

NAT must, therefore, monitor the data stream and modify any and all references to IP addressing schemes. NAT might affect performance, having to scan every packet for references to addressing. The performance degradation is minimal, however, and the benefits of NAT make the performance impact acceptable.

NAT and Encryption

When the data is encrypted within the IP packet, it is, of course, impossible for NAT to perform the internal packet address translations. Thus, these systems should be internally assigned, legally registered, outside addresses, exempted from NAT.

NAT and Security

Unfortunately, NAT limits the number of security options that can be applied. Remember that NAT requires the ability to translate any part of the headers and packets that reference the addressing scheme. Thus IP and TCP checksums need to be accessible, limiting the encryption of these areas.

Advantages and Disadvantages of NAT

Advantages

The most obvious advantage of NAT is that it conserves the legally registered addressing scheme by allowing privatization of intranets, yet allows legal addressing scheme pools to be set up to gain access to the Internet from within the intranet. This scenario, of course, has repercussions on cost savings because of reduced numbers of legally registered classes, along with the centralization of access to the Internet.

Network administrators and managers are at a flexibility advantage. Network design is simplified by the now-limitless availability of addressing schemes, offering many operational and administrative conveniences of growth paths.

Also, when enterprises merge and their networks merge, NAT allows for a seamless merger, while maintaining the currently implemented addressing schemes.

Another advantage is the reduction of instances where addressing schemes overlap. If a scheme was originally set up within an intranet, and then the intranet was connected to the Internet without address translation, the potential for overlap exists globally. This problem is serious because routing protocols cannot provide reliable routing for ambiguous addressing. To guard against such problems, ISPs use routing filters, which are either overlooked or not always in practice. Use of NAT provides a method to avoid such overlaps, yet retains full Internet connectivity.

Another advantage is that NAT can increase the flexibility of connection to the Internet. Multiple pools, backup pools, and load-sharing/balancing pools can be implemented to help ensure reliable Internet connections.

Deprivatization of a network requires renumbering of the existing network; the costs can be associated to the number of hosts that require conversion to the new addressing scheme. NAT allows the existing scheme to remain, and still supports the new assigned addressing scheme publicly.

Disadvantages

One significant disadvantage is the loss of end-to-end IP traceability. It becomes much harder to trace packets that undergo numerous packet changes over multiple NAT hops. This scenario does, however, lead to more secure links because hackers who want to determine a packet's source will find it difficult, if not impossible, to trace or obtain the originating source or destination address.

Switching path delays, of course, are introduced because of the translation of each IP address within the packet headers. This packet modification can place networking design limitations within the intranet.

NAT also forces some applications that use IP addressing schemes to stop functioning because it hides end-to-end IP addresses. Applications that use physical IP addresses instead of a qualified domain name will not reach destinations that are translated across the NAT router. Sometimes this problem can be avoided by implementing static NAT mappings.

NAT Feature Set

NAT is a feature of Cisco IOS software, and it has its own feature subset. NAT allows for both static and dynamic address translation.

Static NAT establishes a one-to-one address mapping between the inside and outside addressing schemes. Thus every time a packet with a specific IP address that is defined in the static NAT configuration reaches an inbound router interface and requests a translation, it receives the same address translation IP matchup. Therefore, the NAT table must have an entry for each inside IP address, outside IP address, and the mapping that correlates the inside and outside addresses.

Dynamic NAT automatically establishes a translation from the pool of inside addresses to a pool of outside addresses, and vice versa. Therefore, when a packet with an IP address defined for translation reaches an inbound router interface and requests a translation, it receives one address from within the pool of IP addressing schemes that it is destined for. When this mapping is defined, it remains until the NAT table is cleared or the mapping period has expired, at which point packets from the same host must obtain another free IP address from the destination pool. The new address may or may not be the address that was previously assigned.

Address overloading allows the conservation of a legal, outside, global IP addressing scheme because it allows the source ports in User Datagram Protocol (UDP) and TCP packets to be translated. When inside local IP addresses are mapped to the same outside global address, each of the inside host's TCP and UDP port numbers are used to make the source or destination distinction, rather then the IP address itself. This scenario is also referred to as Port Address Translation (PAT), which is a many-to-one address mapping. NAT is one-to-one IP address mapping.

Load distribution of TCP packets can be configured for packets destined to the inside from the outside configuring an access list that contains the destination addresses. Then packets destined for the inside address scheme from the outside, which have matching IP addresses within an access list, are given an address from a rotary pool of IP addresses. This allocation is performed on a round-robin basis, and only when a new connection is opened from the outside to the inside is the address assigned from the rotary pool. Therefore, a virtual machine can be configured and specified in an access list. This virtual machine represents many identical systems (identical in resources being shared), and outside users access any one of these resource systems based on load-share distribution.

NAT Operation

NAT can be functionally used in various methods, including:

The remainder of this section explains these various sorts of NAT methodologies and configurations.

NAT of Inside Local Addresses

Figure 3 illustrates the IP packet stream from station B to station A (A#,Red) and back again B#,Blue). First a packet or packets (A1) are thrown out onto the intranet with a destination address of station B (171.69.2.1). intranet routing determines that the packet arrives at the E1 interface (10.1.1.1) of the NAT router (A2). The NAT feature determines that the IP address of station A (10.2.2.1) packets requires translation (A3), since it matches an address range defined by the access list that is linked to the NAT translation table. The NAT router then initially checks its routing table to determine if this is the first instance of packets from that source or destination. If packets containing the same IP address have been translated before, the NAT determines from the NAT table the correct IP address to embed, based on the mapping assignment. If this is the first instance of packets with this IP address that reach the router, the NAT router assigns from the NAT table a new IP address, by one of the two methods:


Figure 3: NAT of Inside Local Address

Thus station B knows the globally unique and legally registered address of station A. On the other hand, station A knows only that station B is at the globally unique and legally registered address defined and mapped within the NAT router; it never knows the actual address 10.2.2.1.

It should be noted that if the inside translated address also resides outside and the NAT router learns this address scheme via dynamic routing, then certain steps must be taken to ensure that the packet transverses the inside Ethernet interface to reach its destination, and not transverse the outside Ethernet interface. If it transversed the outside Ethernet interface, it would go in the wrong direction and cause the packet to go to the wrong intended destination address, even though it is the same address.

NAT with Port Address Translation of Global Addressing

Figure 4 illustrates the IP packet(s) stream from station B to station A and back again, as well as the IP packet(s) stream from station C to station D. The difference here is that the legally registered IP address assigned to the NAT pool is one IP address, 171.69.89.1. Therefore, there are more inside IP hosts than NAT pool-allocated addresses. This inside IP overloading can be handled via the PAT feature of NAT for TCP and UDP connections. Some applications, though, cannot support PAT because they require unique IP addresses per client server connection. Assuming a TCP connection that supports PAT established between stations A and B and C and D, NAT conserves IP addressing by establishing unique socket (socket = address : port) mappings.

Station B opens a TCP connection to station A with a source port assignment of 1024 and a destination port assignment of 23. This scenario is similar to the local address NAT described previously.


Figure 4: NAT with Port Address Translation of Global Addresses

The mapping with regard to an IP address has been discussed, but TCP connections are socket-based connections. Normal NAT assumes unique, legally registered IP portions of socket-based connections. Thus the NAT mapping for the TCP connection would be 171.69.89.1:1024 mapped to 171.69.2.1:23. Now assume that station C tries to establish a connection to station D. Since the pool consists of only one IP address, the next connection to be established will fail, with a destination unreachable error message, because the pool is not able to allocate another outside address. Other mappings are maintained, however.

With the overload feature enabled, however, the connection will not fail. NAT no longer requires uniqueness for the IP portions, but requires uniqueness to the port portion. Therefore, as the next connection establishes, the NAT table is updated with an entry that has the same IP portion of the socket, but a unique port address portion of the socket. Thus, the NAT mapping for the second TCP connection would be 171.69.89.1:1723 mapped to 171.69.3.1:23. In this way, multiple stations can share the same legally registered IP address, further conserving globally unique addresses. Note the same IP address in the two entries discussed, and the different port numbers.

NAT Handling of Overlapping Networks

Figure 5 illustrates what happens when inside networks overlap with outside networks. Note that 171.69.3.0 network exists on both sides of the NAT. This scenario occurs for private networks that do not stick to those addresses assigned by the IANA for privatization. Therefore, other enterprises may contain the same networks; the only difference is that the outside network is legally registered and the inside network is not.

In Figure 5, when station B wants to connect to station D, station B performs a Domain Name System (DNS) lookup for the name-to-address correlation. The NAT router intercepts the DNS lookup reply, recognizes that an IP translation mapping is required (as this overlapped network is specified in an inbound access list), and then performs the translation on the returned address indicated by the DNS server for the domain name.

First the NAT table is set up for packets destined for the DNS, thus mapping 10.2.2.1 to 171.69.89.2. This mapping is taken from the inside to the outside NAT pool. Upon return, the NAT not only transforms the IP 171.69.89.2 to 10.2.2.1, it also creates a new mapping for the outside overlapped network. This mapping is 171.69.3.1 to 10.4.4.1. Therefore, future packets destined for station D will have a destination of 10.4.4.1, which maps to the legally registered address.

What happens if a station outside, say station F, and station E have the exact same IP address? Remember that the source host station B performs a DNS lookup based on the host's name. Thus station E retains the local address 171.69.3.2 and station F now appears to be on network 10.4.4.0, say at address 10.4.4.2. If the host thereafter references the host by physical address, it goes to the internal address, and, to get to the outside destination host station F, the inside source host station B must reference the domain name. The inside host could use the newly allocated address of 10.4.4.2 if it knows it. If both the inside domain name and the inside IP overlap with an outside host, then that outside host is always unreachable.


Figure 5: NAT Handling of Overlapping Networks

NAT Support for TCP Load Distribution

Figure 6 illustrates what happens when multiple inside stations that have mirrored resources that require a unique virtual addressing scheme exist. For example, stations B, G, and H, appear exactly the same to the end host connected to them. Therefore, if station A wishes to access that common shared resource, it could connect to any one of the three stations. In this case, to conserve addresses, NAT can be configured such that by connecting to one virtual station with an unique address, the end user connects to one of the hosts based on a round-robin scheme.

A virtual station with an IP address of 10.2.2.254 is preconfigured, whereby the inside IP address is mapped to a unique outside legal address, 171.69.89.1. Then station A sends out packets destined for this virtual station, at 171.69.89.1. Upon entering the NAT router E0 interface, NAT validates if a translation entry already exists from the source station to the virtual station. Since this is the first reference to the virtual station, NAT creates another mapping between the next real host, 10.2.2.1 for the inside address destination and the source station 171.69.2.1. Therefore, station A communicates to the common shared resource via station B. First the IP destination address is translated from the legal, mapped address for the virtual station to the privatized IP address for the virtual station. That is, the destination IP of 171.69.89.1 is translated to 10.2.2.254. Then, NAT performs another translation by replacing that inside destination IP address for the virtual station with the next available real host's IP address. That is, the destination IP of 10.2.2.254 is translated to 10.2.2.1. The substitution for the real host's IP is based on a round-robin process. Therefore, the next connection to be established has a final destination IP address of 10.2.2.2, and likewise for the next connection after that, 10.2.2.3. Also notice that the mapping is performed between sockets. Therefore, when station A opens another connection to the virtual station via a different port, the NAT treats it as a new connection. Thus, this second connection to the shared common resource is established this time to station G, meaning that the final destination IP address translated is 10.2.2.2.


Figure 6: NAT Support for TCP Load Distribution

NAT Configuration

This section includes details on how to configure the NAT router for the four major functional methods of legal IANA IP address conservation.

Figure 7 illustrates the private network behind the NAT router, and the commands required to support NAT on the border router. The private network consists of the IANA- allocated, non-Internet routable, IP addressing schemes (RFC 1918). This network could have easily been designed with any other IP networking scheme. In addition to the required basic routing configuration, NAT requires the following commands:

Static NAT Configuration

Figure 7, the host's system at IP address 10.1.1.4, requires a unique, legally registered IP address that never changes. This setup is configured as indicated in Figure 7 by using the command:


Router(config)#ip nat inside source static "inside IP address" "outside IP address"

Dynamic NAT Configuration

For the remainder of the network hosts behind the NAT router, an outside IP address is required only when connecting to outside resources. They also do not require the same unique outside address every time they connect to outside hosts. This setup is configured as indicated in the figure by using a combination of commands. First a NAT pool must be configured, from which outside addresses are allocated to the requesting inside hosts. This process is accomplished by using the command:


Router(config)#ip nat pool "pool name" "start outside IP address" "finish outside IP address" netmask "network mask"

Next access lists are defined to determine which inside networks are translated by the NAT router:


Router(config)#access-list "unique access list number" permit "inside IP network address" "inside IP network mask"

or


Router(config)#access-list "unique access list number" deny "inside IP network address" "inside IP network mask"

Finally the NAT pool and the access list are correlated:


Router(config)#ip nat inside source list "unique access list number" pool "pool name"

NAT of Inside Local Addresses


Figure 7: Configuring NAT of Inside Local Addresses

Static and Dynamic NAT Interface Configuration

Now all that is left to do is to enable the NAT on each interface of the NAT router participating in the NAT process; the following commands are applied to the corresponding interfaces:


Router(config)#ip nat inside

and


Router(config)#ip nat outside

It is interesting to note that only one interface may be configured as outside, yet multiple interfaces may be configured as inside.

Also, in static and dynamic NATs, no overlap can exist in the static assigned IP addresses or IP addresses in the dynamic IP pool. An overlap would cause transitional problems. Specifically, the IP address that is configured for both static and dynamic NAT addressing is used in the mapping based on a first-come, first-served basis. In other words, if the IP is assigned dynamically first, then when the system that is configured for static usage of that IP address requests that mapping, the translation fails, and the connection then fails.

A value can be entered that causes NAT mappings to expire after a certain period of time (see Figure 7) This timer value is the length of time the NAT router goes without seeing any packets that require that specific mapping translation. When a mapping expires, it is removed from the table and, if it is a dynamically assigned address, it is returned to the pool for the next requested translation mapping. This timeout can be set using the command:


Router(config)#ip nat translation timeout "time out value in seconds"



Other IP NAT translation parameters include timeouts (in seconds) for DNS, TCP, TCP after FIN or RST or SYN, ICMP, or UDP. These translation parameters are defined in Table 2. A method is also available to specify the maximum number of entries that the NAT translation table may contain. These parameters are issued via the same command as the timeout except, instead of the keyword timeout followed by a value, the following keyword and value are inserted:


Router(config)#ip nat translation "keyword below" "value"


Table 2  : NAT Translation Parameters
Keyword Meaning
dns-timeout Specify timeout for NAT DNS flows
finrst-timeout Specify timeout for NAT TCP flows after a FIN or RST
icmp-timeout Specify timeout for NAT ICMP flows
max-entries Specify maximum number of NAT entries
syn-timeout 23
tcp-timeout Specify timeout for NAT TCP flows
timeout Specify timeout for dynamic NAT translations
udp-timeout Specify timeout for NAT UDP flows

NAT with Port Address Translation of Global Addressing

Figure 8 illustrates the private network behind the NAT router, and the commands required to support NAT on the border router. The private network consists of the IANA-allocated, non-Internet routable, IP addressing schemes (RFC 1918). This network could have easily been designed with any other IP networking scheme. It should be noted here that the NAT pool consists of only one legally registered IP address, yet there are a minimum of six host systems (not including the routers) that may require the use of the dynamic NAT feature. The seventh host system is configured statically and, therefore, always retains the same NAT outside address to inside address mapping. Comparison of this configuration with the previous configuration of private inside addresses (Figure 7), shows that the two are identical, with the exception of one dynamic command:


Router(config)#ip nat inside source list "unique access list number" pool "pool name" overload


Figure 8: Configuring NAT with Port Address Translation of Global Addressing



Defining the IP NAT pool requires adding the overload to the end of the command line to enable PAT of inside global addressing. This keyword, overload, allows for the many-to-one dynamic mapping and maps inside IP addresses to different port addresses for a single, outside IP address. This one-to-many mapping is shown in Table 3.


Table 3  : Router#sho ip nat trans
Pro Inside Global Inside Local Outside Local Outside global
icmp 171.69.89.25:14 10.1.1.5:4 171.69.89.94:4 171.69.89.94:14
icmp 171.69.89.25:13 10.1.1.5:3 171.69.89.94:3 171.69.89.94:13
icmp 171.69.89.25:12 10.1.1.5:2 171.69.89.94:2 171.69.89.94:12
icmp 171.69.89.25:11 10.1.1.5:1 171.69.89.94:1 171.69.89.94:11
icmp 171.69.89.25:10 10.1.1.5:0 171.69.89.94:0 171.69.89.94:10
icmp 171.69.89.25:9 10.1.1.6:4 171.69.89.94:4 171.69.89.94:9
icmp 171.69.89.25:8 10.1.1.6:3 171.69.89.94:3 171.69.89.94:8
icmp 171.69.89.25:7 10.1.1.6:2 171.69.89.94:2 171.69.89.94:7
icmp 171.69.89.25:6 10.1.1.6:1 171.69.89.94:1 171.69.89.94:6
icmp 171.69.89.25:5 10.1.1.6:0 171.69.8 9.94:0 171.69.89.94:5
icmp 171.69.89.25:4 10.1.1.1:4 171.69.89.94:4 171.69.89.94:4
icmp 171.69.89.25:3 10.1.1.1:3 171.69.89.94:3 171.69.89.94:3
icmp 171.69.89.25:2 10.1.1.1:2 171.69.89.94:2 171.69.89.94:2
icmp 171.69.89.25:1 10.1.1.1:1 171.69.89.94:1 171.69.89.94:1
-- -- 10.1.1.1:0 171.69.89.94:0 171.69.89.94:1

In this example, pings to an external address of 171.69.89.94 were performed from the E1 interface of the NAT router, as well as two stations on the 10.1.1.0 network. In the table, a new port is allocated for each ICMP packet. The internal address (inside local) change is based on which station is performing the ping, yet they all map to the same external (inside global)171.69.89.25 IP address with a different incremental port number. The outside local and global are the same since this is a nontranslated return address.

NAT Handling of Overlapping Networks

Figure 9 illustrates the private network behind the NAT router and the commands required to support NAT on the border router. The private network consists of the IANA-allocated, non-Internet routable, IP addressing schemes (RFC 1918). This network could have easily been designed with any other IP networking scheme.

It should be noted here that the NAT pool consists of two IP addressing schemes, net-0 and net-1. The first one is for the inside-to-outside NAT, which consists of outside, legally registered IP addresses, net-0 (171.69.89.2- 171.69.89.254). The second one is for outside-to-inside NAT, which consists of inside privately registered IP addresses, here being defined from the IANA-allocated, non-Internet routable IP addressing scheme, net-1 (10.255.1.1- 10.255.1.254).


Figure 9: Configuring NAT Handling of Overlapping Networks



Comparison of this configuration with the other NAT configurations previously described indicates that the two are identical, with the exception of the definition of the second NAT pool. This was achieved by issuing the following extra commands:


Router(config)#ip nat pool "pool name" "start inside IP address" "finish inside IP address" netmask "network mask"

In this command, the outside pool name is net-1 and the inside pool name is net-0, and a new, nonallocated, private IP addressing scheme is defined for converting outside legal IP addresses to the inside, private, nonlegal addressing scheme. Then the other command required to associate the new pool to the access list defined follows:


Router(config)#ip nat outside source list "unique access list number" pool "pool name"

Notice here that it is an outside source list reference for outside-to-inside NAT, instead of the inside source list reference for the previous configuration of inside-to-outside NAT. Also, notice that the access list did not change, because the concern here is overlapping address schemes; thus the same access list can be applied on both the inbound and the outbound packets that require translation.


Table 4  : Router#sho ip nat trans
Pro Inside Global Inside Local Outside Local Outside Global
icmp 171.69.89.2 10.1.0.1 171.69.88.94 171.69.88.94
-- 171.69.89.3 172.16.2.2 10.255.1.1 171.16.2.2
-- 171.69.89.2 10.1.0.1 -- --
-- -- -- 10.255.1.1 171.16.2.2

Table 4 shows an ICMP ping from 10.1.0.1 to an external host 171.69.88.94. The 10.1.0.1 packet is translated to 171.69.89.2, and from the external host all communication to and from 10.1.0.1 appears as if the host address is really 171.69.89.2. Next, the internal host at 172.16.2.2 wishes to communicate with the external host at 172.16.2.2. They both have the same IP address. The internal host first assigns a translated address to 172.16.2.2, which is 171.69.89.3. Then the internal host requests a DNS lookup of the external host IP address based on its unique domain host name. (It is assumed that these two systems have unique names but the same address. If the names are the same, then these two systems will never communicate.) Upon return, the NAT assigns a translated address to the external host address of 172.16.2.2, which is 10.255.1.1. Thus the internal host sees the external host as 10.255.1.1. In this way, they can communicate, even though they both have the same address.

NAT Support for TCP Load Distribution

Figure 10 illustrates the private network behind the NAT router, and the commands required to support NAT on the border router, with TCP load sharing enabled. The private network consists of the IANA-allocated, non-Internet routable, IP addressing schemes (RFC 1918). This network could have easily been designed with any other IP networking scheme. It should be noted here that the NAT pool now consists of three IP addressing schemes: net-0 (171.69.89.2- 171.69.89.254), net-1 (10.255.1.1-10.255.1.254), and net-2 (192.168.2.2-192.168.2.4). The first one is for the inside-to-outside NAT, which consists of outside, legally registered, IANA IP addresses. The second one is for outside-to-inside NAT, which consists of inside, privately registered IP addresses, here being defined from the IANA-allocated, non-Internet routable, IP addressing scheme (RFC 1918). The third and final defined network is configured to support TCP load sharing for three real systems on the 192.168.2.0 network, which again is defined from the IANA-allocated, non-Internet routable, IP addressing scheme (RFC 1918). These three machines are sharing a common resource that is mirrored across all three machines. Comparison of this configuration with the other NAT configurations previously described shows that they are similar, with the exceptions of the definition of the third NAT pool, a second access list for the virtual host, and the correlation statement between the TCP load-share network pool and the access list. Thus, TCP load sharing is achieved by issuing the following extra commands:


Router(config)#ip nat pool "pool name" "start inside IP address" "finish inside IP address" netmask "network mask" type rotary 

In this command, the pool name for the real hosts on network 192.168.2.0 is net-2, and the pool range for real hosts (not virtual host) is allocated from the private IP addressing scheme. Also note that the type rotary command is added to the end to allow for round-robin load sharing across the real hosts.

Next a new access list needs to be configured for the virtual machine to allow systems to access this host, even though it physically does not exist. This scenario is accomplished by the command:


Router(config)#access-list "unique access list number" permit "virtual host IP address" "virtual hosts IP network mask"


Figure 10: Configuring NAT Support for TCP Load Distribution



Thus the access list is configured by the unique number 2, and the virtual host address and mask are 192.168.2.254 255.255.255.255. Then the other command required to associate the new pool for the real hosts to the access list for the virtual host is defined by:


Router(config)#ip nat inside destination list "unique access list number" pool "pool name"

Notice here the reference to the inside destination of the virtual host defined in access list 2, and the correlation with the NAT pool defined by net-2.

In this way, when an external host tries to establish a connection to 192.168.2.254, NAT forwards the request to one of the three hosts that translate from 192.168.2.254, based on a round-robin fashion. These three resources must be mirror images, such that when a user hits any one of them they have access to identical resources. NAT performs a translation of 192.168.2.254 to 192.168.2.2, for the first request to 192.168.2.254; then it creates a second translation of 192.168.2.254 to 192.168.2.3, upon the second request; and finally, on a third request, the NAT translates 192.168.2.254 to 192.168.2.4. Then all subsequent requests travel round-robin between these three, to supply TCP load sharing of 192.168.2.254 across three systems.

NAT Monitoring and Debugging Features

After a specific type of NAT is configured on the NAT border router, it may be necessary to examine the NAT table and occasionally reset it. Also, if unexpected behavior results after the NAT feature has been configured, it may be necessary to gather debug information to troubleshoot the cause of the unexpected behavior. The following commands will help in these areas.

NAT Table Monitoring Feature

There are two basic NAT monitoring commands:


Router#show ip nat statistical

and


Router#show ip nat translations

They are shown with output for Figure 11.The statistical monitor shows a variety of data, based on NAT's relationship with the NAT router's physical interfaces, the number of translations that were successful, the number that failed or expired because of timeout, the number of inside and outside networks, the IP schemes assigned to those networks, the number of static verses dynamic mappings, and the access lists that are implemented.


Figure 11: NAT Table Monitoring Feature



The translations show the current mappings allocated by the NAT router. This is the NAT table, with inside IP-to-outside IP mappings currently in use, or used prior to the timeout value, if specified.

Clear NAT Table Feature

To clear the statistical information, simply apply the command:


Router#clear ip nat statistics

Likewise, to clear the NAT table of all current mappings, or more specific mappings, issue the following commands:


Router#clear ip nat translations *

This command clears all entries in the NAT table. Other commands are more specific as to which entry to clear from the NAT table. They include:


Router#clear ip nat translations inside "local-ip" "global-ip"

Router#clear ip nat translations outside "local-ip" "global-ip"

Router#clear ip nat translations inside "local-ip" "global-ip" outside "local-ip" "global-ip"

Router#clear ip nat translations udp "local-ip" "global-ip"

Router#clear ip nat translations tcp "local-ip" "global-ip"

All these commands have options to specify the exact IP map to delete, as shown below.



The inside option clears a simple inside translation mapping, or both the inside and the outside translation mapping. The outside option clears an outside translation mapping (but not an inside mapping). The UDP- and TCP-specific features clear the specific protocol-based mapping from the table based on the supplied IP.

It is interesting to note here that after NAT translations are set up and being used, it is impossible to modify the configuration unless all mapping in use that is related to the translation table to be modified is cleared. Thus if a mapping exists for a table called net-0, then no configuration lines referencing net-0 can be modified until the translations using net-0 are cleared.

Debugging NAT Feature


DIAL_4500_NAT#debug ip nat ?

 <1-99> Access list

 detailed NAT detailed events

 <cr> 

DIAL_4500_NAT#debug ip nat 1 detailed

IP NAT detailed debugging is on


! ICMP Echo (ping) From Inside to Outside 

Sep 16 22:18:26.791 PDT: NAT: i: icmp (192.168.1.3, 0) -> (171.69.89.94, 0) [5]

Sep 16 22:18:26.795 PDT: NAT: o: icmp (171.69.89.94, 0) -> (171.69.241.35, 0) [63998]

Sep 16 22:18:26.799 PDT: NAT: i: icmp (192.168.1.3, 1) -> (171.69.89.94, 1) [6]

Sep 16 22:18:26.799 PDT: NAT: o: icmp (171.69.89.94, 1) -> (171.69.241.35, 1) [64510]

Sep 16 22:18:26.807 PDT: NAT: i: icmp (192.168.1.3, 2) -> (171.69.89.94, 2) [7]

Sep 16 22:18:26.807 PDT: NAT: o: icmp (171.69.89.94, 2) -> (171.69.241.35, 2) [65022]

Sep 16 22:18:26.815 PDT: NAT: i: icmp (192.168.1.3, 3) -> (171.69.89.94, 3) [8]

Sep 16 22:18:26.815 PDT: NAT: o: icmp (171.69.89.94, 3) -> (171.69.241.35, 3) [65534]

Sep 16 22:18:26.819 PDT: NAT: i: icmp (192.168.1.3, 4) -> (171.69.89.94, 4) [9]

Sep 16 22:18:26.823 PDT: NAT: o: icmp (171.69.89.94, 4) -> (171.69.241.35, 4) [511]

! Telnet Connection from Inside to Outside

Sep 16 22:18:42.575 PDT: NAT: i: tcp (192.168.1.3, 11012) -> (172.22.16.139, 23)[0]

Sep 16 22:18:44.579 PDT: NAT: i: tcp (192.168.1.3, 11012) -> (172.22.16.139, 23)[0]

Sep 16 22:18:44.583 PDT: NAT*: o: 6 packet (172.22.16.139, 23) -> (171.69.241.35, 11012) [0]

Sep 16 22:18:44.587 PDT: NAT*: i: 6 packet (192.168.1.3, 11012) -> (172.22.16.139, 23) [1]

Sep 16 22:18:44.587 PDT: NAT*: i: 6 packet (192.168.1.3, 11012) -> (172.22.16.139, 23) [2]

Sep 16 22:18:44.591 PDT: NAT*: i: 6 packet (192.168.1.3, 11012) -> (172.22.16.139, 23) [3]

Sep 16 22:18:44.591 PDT: NAT*: o: 6 packet (172.22.16.139, 23) -> (171.69.241.35, 11012) [1]

Sep 16 22:18:44.595 PDT: NAT*: i: 6 packet (192.168.1.3, 11012) -> (172.22.16.139, 23) [4]

Sep 16 22:18:44.599 PDT: NAT*: i: 6 packet (192.168.1.3, 11012) -> (172.22.16.139, 23) [5]

Sep 16 22:18:44.619 PDT: NAT*: o: 6 packet (172.22.16.139, 23) -> (171.69.241.35, 11012) [2]

Sep 16 22:18:44.623 PDT: NAT*: o: 6 packet (172.22.16.139, 23) -> (171.69.241.35, 11012) [3]

Sep 16 22:18:44.623 PDT: NAT*: o: 6 packet (172.22.16.139, 23) -> (171.69.241.35, 11012) [4]

Sep 16 22:18:44.627 PDT: NAT*: o: 6 packet (172.22.16.139, 23) -> (171.69.241.35, 11012) [5]

Sep 16 22:18:44.627 PDT: NAT*: o: 6 packet (172.22.16.139, 23) -> (171.69.241.35, 11012) [6]

Sep 16 22:18:44.639 PDT: NAT*: i: 6 packet (192.168.1.3, 11012) -> (172.22.16.139, 23) [6]

Sep 16 22:18:44.647 PDT: NAT*: o: 6 packet (172.22.16.139, 23) -> (171.69.241.35, 11012) [7]

Sep 16 22:18:44.647 PDT: NAT*: i: 6 packet (192.168.1.3, 11012) -> (172.22.16.139, 23) [7]

Sep 16 22:18:44.647 PDT: NAT*: i: 6 packet (192.168.1.3, 11012) -> (172.22.16.139, 23) [8]

Sep 16 22:18:44.951 PDT: NAT*: i: 6 packet (192.168.1.3, 11012) -> (172.22.16.139, 23) [9]

Sep 16 22:18:44.995 PDT: NAT*: o: 6 packet (172.22.16.139, 23) -> (171.69.241.35, 11012) [8]

Sep 16 22:19:04.639 PDT: NAT: o: tcp (172.22.16.139, 23) -> (171.69.241.35, 11012) [15]

Sep 16 22:19:04.643 PDT: NAT*: i: 6 packet (192.168.1.3, 11012) -> (172.22.16.139, 23) [22]

Sep 16 22:19:04.671 PDT: NAT: i: tcp (192.168.1.3, 11012) -> (172.22.16.139, 23) [23]

Sep 16 22:19:04.675 PDT: NAT*: o: 6 packet (172.22.16.139, 23) -> (171.69.241.35, 11012) [16]

DIAL_4500_NAT#undebug all

To enable debugging of NAT, the following command must be issued on the command line of the NAT router:


Router#debug ip nat "access-list number" detailed

The access-list number associated with the NAT translation pool needs to be specified. The detailed option allows for more-verbose information gathering. The above console output has two examples of debug output; one is for an inside-to-outside ping operation, while the other is for an inside-to-outside Telnet host connection.

Reading the debug information is quite easy. The date and time are given for event sequencing, followed by the NAT-related event. The asterisks (*) indicate that the packet translation is happening in the fast path. The first packet in the translation always follows the slow path, meaning that packet is process switched and cached. All remaining packets follow the fast path using the previous cached entry. The "i" and "o" specify whether the addressing scheme refers to inside or outside, respectively. The first IP address is from the source addressing scheme, while the second IP address is from the destination addressing scheme. The ++ indicates the translation imposed.


Sep 16 22:18:26.791 PDT: NAT: i: icmp (192.168.1.3, 0) -> (171.69.89.94, 0) [5]

Sep 16 22:18:26.795 PDT: NAT: o: icmp (171.69.89.94, 0) -> (171.69.241.35, 0) [63998]

Therefore, these two lines taken from the debug of the ping operation show that an inside ICMP request from the host at 192.168.1.3 went across the NAT router to the outside address 171.69.89.94. Likewise, the second line shows that the return echo response from the outside source address 171.69.89.94 went across the NAT router to 171.69.241.35. The echo response reaches the original source host at 192.168.1.3, since there is an inside-to-outside mapping. The inside address of 192.168.1.3 was translated into 171.69.241.35. Thus external hosts see the inside host at 171.69.241.35 and not at 192.168.1.3, which is its true IP address. This is seen in Table 5. (Note: The second number in the parenthesis indicates the IP address and port number.)


Table 5  : DIAL_4500_NAT#show ip nat translations verbose
Pro Inside Global Inside Local Outside Local Outside Global
-- 172.22.20.3 192.168.5.2 -- --
-- 171.69.241.35 192.168.1.3 -- --
-- 171.69.241.34 192.168.2.4 -- --

Conclusion

Network Address Translation (NAT) is a viable method for controlling the problem of IP address depletion and scalable routing of the existing and future addressing schemes, as TCP/IP proliferates throughout the Internet. Enterprises can benefit from reduced numbers of unique, globally registered, IP addressing schemes; in addition, they can change ISP vendors without renumbering complete enterprise networks. This solution also saves ISPs the expensive costs of registering large numbers of address classes. Other features, such as load sharing, further add to the reusability of the addressing schemes allocated for NAT pools.

Finally, NAT can be considered as the Internet's first environmentally friendly feature, which allows use and reuse of addressing. Because the IANA is running out of addresses, a solution needs to be found, and NAT is that solution.

References


  1. Cisco Systems, INC. DesigNAT: IP Network Address Translation Design Document, San Jose California, May 1996.

  2. Cray Communications, Inc. The IP Network Address Translator (NAT), RFC 1631, May 1994.

  3. Cisco Systems, Inc. Address Allocation for Private Internets, RFC 1918, San Jose, California, February 1996.

  4. Cisco Systems, INC. Network Address Translation (NAT), Internal training document, San Jose, California, 1996.

guestbar
Posted: Thu Feb 26 14:40:38 PST 1998

All contents copyright © 1998 Cisco Systems, Inc. Important Notices.