NAT operations and router configuration have already been described in Chapter 8. NAT is a mechanism that allows address conservation and at the same time increases the environment’s security level, as inside devices are not directly reachable from outside the network.
NAT Functionality
There are multiple ways to configure NAT on your router, depending on your particular requirements. To configure NAT, you need to tell the router which interfaces are on the inside and outside of your NAT network. You could actually swap internal addresses for a pool of NAT addresses, or, at the very least, a single NAT address, and perform NAT between two interfaces on your router.
NAT enables hosts on private networks to access resources on the Internet or other public networks. NAT is an IETF standard that enables a LAN to use one set of IP addresses for internal traffic, typically private address space as defined in RFC 1918, and another set of addresses for external traffic, typically publicly registered IP address space.
NAT converts the packet headers for incoming and outgoing traffic and keeps track of each session. Some NAT-specific terms include the following:
- Inside interface
- Inside local address
- Inside global address
- Outside interface
- Outside local address
- Outside global address
In NAT terminology, the inside interface is the border interface of the administrative domain controlled by the organization. This does not necessarily have to be the default gateway used by hosts that reside within the internal network.
The inside local address is the IP address of a host residing on the inside network. In most cases, the inside local address is an RFC 1918 address (i.e., non-routable, such as 10.x.x.x, 192.168.x.x, or 172.16.x.x to 172.31.x.x). This address is translated to the outside global address, which is typically an IP address from a publically assigned or registered pool. It is important to remember, however, that the inside local address could also be a public address.
The inside global address is the IP address of an internal host as it appears to the outside world. Once the inside IP address has been translated, it will appear as an inside global address to the Internet public or to any other external network or host.
The outside interface is the boundary for the administrative domain that is not controlled by the organization. In other words, the outside interface is connected to the external network, which may be the Internet or any other external network, such as a partner network, for example. Any hosts residing beyond the outside interface fall outside the local organization’s administration.
The outside local address is the IP address of an outside, or external, host as it appears to inside hosts. Finally, the outside global address is an address that is legal and can be used on the Internet. Both outside local addresses and outside global addresses are typically allocated from a globally routable address or network space.
To clarify these concepts further, Figure 31.4 below shows the use of the addresses in a session between two hosts; NAT is enabled on the intermediate gateway:
Figure 31.4 – NAT Inside and Outside Addresses
NAT Configuration
We will exemplify NAT configuration on a Cisco device. The following steps should be performed:
- Designate one or more interfaces as the internal (inside) interface(s) using the ip nat inside interface configuration command.
- Designate an interface(s) as the external (outside) interface using the ip nat outside interface configuration command.
- Configure an ACL that will match all traffic for translation. This can be a standard or an extended named or numbered ACL.
- Optionally, configure a pool of global addresses using the ip nat pool <name> <start-ip> <end-ip> [netmask <mask> | prefix-length <length>] global configuration command. This defines a pool of inside global addresses to which inside local addresses will be translated.
- Configure NAT globally using the ip nat inside source list <ACL> [interface|pool] <name> [overload] global configuration command.
The following output shows you how to configure basic NAT with Cisco IOS software. You can see that the configuration has used the description and remark keywords to help administrators more easily manage and troubleshoot their networks:
| Router(config)#interface FastEthernet0/0
Router(config-if)#description ‘Connected To The Internal LAN’ Router(config-if)#ip address 10.5.5.1 255.255.255.248 Router(config-if)#ip nat inside Router(config-if)#exit Router(config)#interface Serial0/0 Router(config-if)#description ‘Connected To The ISP’ Router(config-if)#ip address 150.1.1.1 255.255.255.248 Router(config-if)#ip nat outside Router(config-if)#exit Router(config)#access-list 100 remark ‘Translate Internal Addresses Only’ Router(config)#access-list 100 permit ip 10.5.5.0 0.0.0.7 any Router(config)#ip nat pool INSIDE-POOL 150.1.1.3 150.1.1.6 prefix-length 24 Router(config)#ip nat inside source list 100 pool INSIDE-POOL
|
Following this configuration, the show ip nat translations command can be used to verify that translations are actually taking place on the router, as illustrated below:
| Router#show ip nat translations
Pro Inside global Inside local Outside local Outside global icmp 150.1.1.4:4 10.5.5.1:4 200.1.1.1:4 200.1.1.1:4 icmp 150.1.1.3:1 10.5.5.2:1 200.1.1.1:1 200.1.1.1:1 tcp 150.1.1.5:159 10.5.5.3:159 200.1.1.1:23 200.1.1.1:23
|
There are actually three choices when it comes to configuring NAT on a router:
- Swap one internal address for one external address (Static NAT)
- Swap many internal addresses for two or more external addresses (Dynamic NAT)
- Swap many internal addresses for many external ports (Port Address Translation)
Static NAT
This technique allows you to swap one specific address for another address when you have a Web server, for example, on the inside of your network. If you are using dynamic addressing, then there is no way routing will work because the inbound packet has no routing table entry.
We will consider an example for the IP pair listed below:
|
Inside Addresses |
Outside NAT Addresses |
|
192.168.1.1 |
200.1.1.1 |
|
192.168.2.1 |
200.1.1.2 |
The static NAT configuration would be as follows:
| Router(config)#interface f0/0
Router(config-if)#ip address 192.168.1.1 255.255.255.0 Router(config-if)#ip nat inside Router(config)#interface f0/1 Router(config-if)#ip address 192.168.2.1 255.255.255.0 Router(config-if)#ip nat inside Router(config)#interface s0/0 Router(config-if)#ip nat outside Router(config-if)#exit Router(config)#ip nat inside source static 192.168.1.1 200.1.1.1 Router(config)#ip nat inside source static 192.168.2.1 200.1.1.2
|
The ip nat inside and ip nat outside commands tell the router which are the inside NAT interfaces and which are the outside NAT interfaces. The ip nat inside source command defines the static translations, of which you could have as many as you wish as long as you paid for the public IP addresses.
Dynamic NAT or NAT Pool
You will often need to use a group, or pool, of routable addresses. One-to-one NAT mapping has its limitations, of course, expense and extensive lines of configuration on the router to name two. Dynamic NAT allows you to configure one or more groups of addresses to be used by internal hosts.
If you issued a show ip nat translations command on the router when the inside hosts have made outside connections, you would see a chart containing something like this:
|
Inside Addresses |
Outside NAT Addresses |
|
192.168.1.3 |
200.1.1.11 |
|
192.168.1.2 |
200.1.1.14 |
In the output below, you have internal addresses using a pool of addresses from 200.1.1.1 to 16. The configuration to achieve dynamic NAT is as follows:
| Router(config)#interface f0/0
Router(config-if)#ip nat inside Router(config)#interface s0/1 Router(config-if)#ip nat outside Router(config)#ip nat pool poolname 200.1.1.1 200.1.1.16 netmask 255.255.255.0 Router(config)#ip nat inside source list 1 pool poolname Router(config)#access-list 1 permit 192.168.1.0 0.0.0.255
|
The ACL is used to tell the router which addresses it can and cannot translate. The subnet mask is actually reversed and is called a wildcard mask, which was covered in Chapter 28. All NAT pools need a name, and in this example it is simply called “poolname.” The source list refers to the ACL.
NAT Overload/Port Address Translation
IP addresses are in short supply, and if you have hundreds or thousands of addresses that need to be routed, it could cost you a lot of money. In this instance, you can use NAT overload, also referred to as Port Address Translation (PAT). PAT cleverly allows a port number to be added to the IP address as a way of uniquely identifying it from another translation using the same IP address. There are over 65,000 ports available per IP address.
The show ip nat translations table this time would show the IP addresses and port numbers:
|
Inside Addresses |
Outside NAT Addresses (with Port Numbers) |
|
192.168.1.1 |
200.1.1.1:30922 |
|
192.168.2.1 |
200.1.1.2:30975 |
To configure PAT, you would carry out the exact same configuration as for dynamic NAT (or use the outside interface), but you would add the keyword [overload] to the end of the pool:
|
Router(config)#interface f0/0 Router(config-if)#ip nat inside Router(config)#interface s0/1 Router(config-if)#ip nat outside Router(config)#ip nat pool poolname 200.1.1.1 200.1.1.1 netmask 255.255.255.0 Router(config)#ip nat inside source list 1 pool poolname overload Router(config)#access-list 1 permit 192.168.1.0 0.0.0.255
|
NAT Design Considerations
NAT and PAT are usually performed on firewalls or security appliances, which have some powerful tools to accomplish these tasks:
- Static NAT
- Dynamic NAT
- Identity NAT
- Policy NAT
A recommended best practice is to try to avoid using NAT on internal networks, except for situations in which NAT is required as a stop-gap measure during some mergers or migrations. NAT should not be performed between the Access Layer and the Distribution Layer or between the Distribution Layer and the Core Layer, as this will prevent address translation between OSPF areas, for example.
Organizations in merger processes usually use the same internal network addressing schemes and this can be managed with NAT overlapping techniques (also referred to as bidirectional NAT) that can be used to help translate between the two organizations when they have an overlapping internal IP addressing space that uses RFC 1918 addressing.
If you have internal servers or servers in the DMZ that are reached using translated addresses, it is a good practice to isolate these servers into their own address space and VLAN, possibly using private VLANs. NAT is often used to support content load balancing servers, which usually have to be isolated using source-NAT or destination-NAT.
NAT can also be used in the data center to support a management VLAN that is out-of-band from production traffic. NAT should also be implemented on devices that cannot route or cannot define a gateway for the management VLAN. This allows for smaller management VLANs, rather than a single large management VLAN that covers the entire data center.
In addition, large companies or Internet entities can exchange their summary routes and then they can translate with NAT blocks in the network. This will offer faster convergence but the downside is an increased troubleshooting process because of using NAT/PAT.
PAT is harder to troubleshoot because one or a few IP addresses are used to represent hundreds or maybe thousands of internal hosts, all using TCP and UDP ports to create logical sockets. This increases the complexity of the troubleshooting process because it is difficult to know which IP address is assigned to a particular host, as each host uses a shared IP address and a port number.
If the organization is connected to several different partners or vendors, each partner can be represented by a different NAT block, which can be translated to the organization.
