Why Use NAT?
Each computer and device within an IP network is assigned a unique IP address that identifies the host. Because of a shortage of public IPv4 addresses, most of these IP addresses are private, not routable anywhere outside of the private company network. RFC 1918 defines the private IP addresses you can use internally that should not be advertised:
- 10.0.0.0 through 10.255.255.255
- 172.16.0.0 through 172.31.255.255
- 192.168.0.0 through 192.168.255.255
One of the main functions of NAT is to enable private IP networks to connect to the Internet. NAT replaces a private IP address with a public IP address, translating the private addresses in the internal private network into legal, routable addresses that can be used on the public Internet. In this way, NAT conserves public addresses because it can be configured to advertise at a minimum only one public address for the entire network to the outside world.
Other functions of NAT include:
- Security—Keeping internal IP addresses hidden discourages direct attacks.
- IP routing solutions—Overlapping IP addresses are not a problem when you use NAT.
- Flexibility—You can change internal IP addressing schemes without affecting the public addresses available externally; for example, for a server accessible to the Internet, you can maintain a fixed IP address for Internet use, but internally, you can change the server address.
Note NAT is not required. If you do not configure NAT for a given set of traffic, that traffic will not be translated, but will have all of the security policies applied as normal.
Figure 11-1 shows a typical NAT example, with a private network on the inside.
Figure 11-1 NAT Example
1. When the HR host at 10.1.2.27 sends a packet to a web server, the real source address of the packet, 10.1.2.27, is changed to a mapped address, 22.214.171.124.
2. When the server responds, it sends the response to the mapped address, 126.96.36.199, and the ASA 1000V receives the packet because the ASA 1000V performs proxy ARP to claim the packet.
3. The ASA 1000V then changes the translation of the mapped address, 188.8.131.52, back to the real address, 10.1.2.27, before sending it to the host.
NAT Types Overview
You can implement NAT using the following methods:
- Static NAT—A consistent mapping between a real and mapped IP address. Allows bidirectional traffic initiation. See the “Static NAT” section.
- Dynamic NAT—A group of real IP addresses are mapped to a (usually smaller) group of mapped IP addresses, on a first come, first served basis. Only the real host can initiate traffic. See the “Dynamic NAT” section.
- Dynamic Port Address Translation (PAT)—A group of real IP addresses are mapped to a single IP address using a unique source port of that IP address. See the “Dynamic PAT” section.
- Identity NAT—A real address is statically transalted to itself, essentially bypassing NAT. You might want to configure NAT this way when you want to translate a large group of addresses, but then want to exempt a smaller subset of addresses. See the “Identity NAT” section.
This section describes static NAT and includes the following topics:
Information About Static NAT
Static NAT creates a fixed translation of a real address to a mapped address. Because the mapped address is the same for each consecutive connection, static NAT allows bidirectional connection initiation, both to and from the host (if an access rule exists that allows it). With dynamic NAT and PAT, on the other hand, each host uses a different address or port for each subsequent translation, so bidirectional initiation is not supported.
Figure 11-2 shows a typical static NAT scenario. The translation is always active so both real and remote hosts can initiate connections.
Figure 11-2 Static NAT
Information About Static NAT with Port Translation
Static NAT with port translation lets you specify a real and mapped protocol (TCP or UDP) and port.
This section includes the following topics:
Information About Static NAT with Port Address Translation
When you specify the port with static NAT, you can choose to map the port and/or the IP address to the same value or to a different value.
Figure 11-3 shows a typical static NAT with port translation scenario showing both a port that is mapped to itself and a port that is mapped to a different value; the IP address is mapped to a different value in both cases. The translation is always active so both translated and remote hosts can initiate connections.
Figure 11-3 Typical Static NAT with Port Translation Scenario
Note For applications that require application inspection for secondary channels (for example, FTP and VoIP), the ASA 1000V automatically translates the secondary ports.
Static NAT with Identity Port Translation
The following static NAT with port translation example provides a single address for remote users to access FTP, HTTP, and SMTP. These servers are actually different devices on the real network, but for each server, you can specify static NAT with port translation rules that use the same mapped IP address, but different ports. (See Figure 11-4. See the “Single Address for FTP, HTTP, and SMTP (Static NAT-with-Port-Translation)” section for details on how to configure this example.)
Figure 11-4 Static NAT with Port Translation
Static NAT with Port Translation for Non-Standard Ports
You can also use static NAT with port translation to translate a well-known port to a non-standard port or vice versa. For example, if inside web servers use port 8080, you can allow outside users to connect to port 80, and then undo translation to the original port 8080. Similarly, to provide extra security, you can tell web users to connect to non-standard port 6785, and then undo translation to port 80.
Static Interface NAT with Port Translation
You can configure static NAT to map a real address to an interface address/port combination. For example, if you want to redirect Telnet access for the ASA 1000V security profile interface to an outside host, then you can map the outside host IP address/port 23 to the ASA 1000V interface address/port 23. Because the inside security profile interfaces do not have IP addresses, you cannot use static interface PAT on the inside.
Information About One-to-Many Static NAT
Typically, you configure static NAT with a one-to-one mapping. However, in some cases, you might want to configure a single real address to several mapped addresses (one-to-many). When you configure one-to-many static NAT, when the real host initiates traffic, it always uses the first mapped address. However, for traffic initiated to the host, you can initiate traffic to any of the mapped addresses, and they will be untranslated to the single real address.
Figure 11-5 shows a typical one-to-many static NAT scenario. Because initiation by the real host always uses the first mapped address, the translation of real host IP/1st mapped IP is technically the only bidirectional translation.
Figure 11-5 One-to-Many Static NAT
For example, you have a load balancer at 10.1.2.27. Depending on the URL requested, it redirects traffic to the correct web server (see Figure 11-6). (See the “Inside Load Balancer with Multiple Mapped Addresses (Static NAT, One-to-Many)” section for details on how to configure this example.)
Figure 11-6 One-to-Many Static NAT
Information About Other Mapping Scenarios (Not Recommended)
The ASA 1000V has the flexibility to allow any kind of static mapping scenario: one-to-one, one-to-many, but also few-to-many, many-to-few, and many-to-one mappings. We recommend using only one-to-one or one-to-many mappings. These other mapping options might result in unintended consequences.
Functionally, few-to-many is the same as one-to-many; but because the configuration is more complicated and the actual mappings may not be obvious at a glance, we recommend creating a one-to-many configuration for each real address that requires it. For example, for a few-to-many scenario, the few real addresses are mapped to the many mapped addresses in order (A to 1, B to 2, C to 3). When all real addresses are mapped, the next mapped address is mapped to the first real address, and so on until all mapped addresses are mapped (A to 4, B to 5, C to 6). This results in multiple mapped addresses for each real address. Just like a one-to-many configuration, only the first mappings are bidirectional; subsequent mappings allow traffic to be initiated to the real host, but all traffic from the real host uses only the first mapped address for the source.
Figure 11-7 shows a typical few-to-many static NAT scenario.
Figure 11-7 Few-to-Many Static NAT
For a many-to-few or many-to-one configuration, where you have more real addresses than mapped addresses, you run out of mapped addresses before you run out of real addresses. Only the mappings between the lowest real IP addresses and the mapped pool result in bidirectional initiation. The remaining higher real addresses can initiate traffic, but traffic cannot be initiated to them (returning traffic for a connection is directed to the correct real address because of the unique 5-tuple (source IP, destination IP, source port, destination port, protocol) for the connection).
Note Many-to-few or many-to-one NAT is not PAT. If two real hosts use the same source port number and go to the same outside server and the same TCP destination port, and both hosts are translated to the same IP address, then both connections will be reset because of an address conflict (the 5-tuple is not unique).
Figure 11-8 shows a typical many-to-few static NAT scenario.
Figure 11-8 Many-to-Few Static NAT
Instead of using a static rule this way, we suggest that you create a one-to-one rule for the traffic that needs bidirectional initiation, and then create a dynamic rule for the rest of your addresses.
This section describes dynamic NAT and includes the following topics:
Information About Dynamic NAT
Dynamic NAT translates a group of real addresses to a pool of mapped addresses that are routable on the destination network. The mapped pool typically includes fewer addresses than the real group. When a host you want to translate accesses the destination network, the ASA 1000V assigns the host an IP address from the mapped pool. The translation is created only when the real host initiates the connection. The translation is in place only for the duration of the connection, and a given user does not keep the same IP address after the translation times out. Users on the destination network, therefore, cannot initiate a reliable connection to a host that uses dynamic NAT, even if the connection is allowed by an access rule.
Figure 11-9 shows a typical dynamic NAT scenario. Only real hosts can create a NAT session, and responding traffic is allowed back.
Figure 11-9 Dynamic NAT
Figure 11-10 shows a remote host attempting to initiate a connection to a mapped address. This address is not currently in the translation table; therefore, the ASA 1000V drops the packet.
Figure 11-10 Remote Host Attempts to Initiate a Connection to a Mapped Address
Note For the duration of the translation, a remote host can initiate a connection to the translated host if an access rule allows it. Because the address is unpredictable, a connection to the host is unlikely. Nevertheless, in this case you can rely on the security of the access rule.
Dynamic NAT Disadvantages and Advantages
Dynamic NAT has these disadvantages:
- If the mapped pool has fewer addresses than the real group, you could run out of addresses if the amount of traffic is more than expected.
Use PAT or a PAT fallback method if this event occurs often because PAT provides over 64,000 translations using ports of a single address.
- You have to use a large number of routable addresses in the mapped pool, and routable addresses may not be available in large quantities.
The advantage of dynamic NAT is that some protocols cannot use PAT. PAT does not work with the following:
- IP protocols that do not have a port to overload, such as GRE version 0.
- Some multimedia applications that have a data stream on one port, the control path on another port, and are not open standard.
See the “Default Settings” section for more information about NAT and PAT support.
This section describes dynamic PAT and includes the following topics:
Information About Dynamic PAT
Dynamic PAT translates multiple real addresses to a single mapped IP address by translating the real address and source port to the mapped address and a unique port. If available, the real source port number is used for the mapped port. However, if the real port is not available, by default the mapped ports are chosen from the same range of ports as the real port number: 0 to 511, 512 to 1023, and 1024 to 65535. Therefore, ports below 1024 have only a small PAT pool that can be used. (8.4(3) and later, not including 8.5(1)) If you have a lot of traffic that uses the lower port ranges, you can now specify a flat range of ports to be used instead of the three unequal-sized tiers.
Each connection requires a separate translation session because the source port differs for each connection. For example, 10.1.1.1:1025 requires a separate translation from 10.1.1.1:1026.
Figure 11-11 shows a typical dynamic PAT scenario. Only real hosts can create a NAT session, and responding traffic is allowed back. The mapped address is the same for each translation, but the port is dynamically assigned.
Figure 11-11 Dynamic PAT
After the connection expires, the port translation also expires after 30 seconds of inactivity. The timeout is not configurable. Users on the destination network cannot reliably initiate a connection to a host that uses PAT (even if the connection is allowed by an access rule).
Note For the duration of the translation, a remote host can initiate a connection to the translated host if an access rule allows it. Because the port address (both real and mapped) is unpredictable, a connection to the host is unlikely. Nevertheless, in this case you can rely on the security of the access rule.
Dynamic PAT Disadvantages and Advantages
Dynamic PAT lets you use a single mapped address, thus conserving routable addresses. You can even use the ASA 1000V outside interface IP address as the PAT address. (The inside security profile interfaces do not have IP addresses, so you cannot use interface PAT on the inside).
Dynamic PAT does not work with some multimedia applications that have a data stream that is different from the control path. See the “Default Settings” section for more information about NAT and PAT support.
Dynamic PAT may also create a large number of connections appearing to come from a single IP address, and servers might interpret the traffic as a DoS attack. You can configure a PAT pool of addresses and use a round-robin assignment of PAT addresses to mitigate this situation.
You might have a NAT configuration in which you need to translate an IP address to itself. For example, if you create a broad rule that applies NAT to every network, but want to exclude one network from NAT, you can create a static NAT rule to translate an address to itself. Identity NAT is necessary for remote access VPN, where you need to exempt the client traffic from NAT.
Figure 11-12 shows a typical identity NAT scenario.
Figure 11-12 Identity NAT
How NAT is Implemented
The ASA 1000V can implement address translation in two ways: network object NAT and twice NAT. This section includes the following topics:
Main Differences Between Network Object NAT and Twice NAT
The main differences between these two NAT types are:
- How you define the real address.
– Network object NAT—You define NAT as a parameter for a network object. A network object names an IP host, range, or subnet so you can then use the object in configuration instead of the actual IP addresses. The network object IP address serves as the real address. This method lets you easily add NAT to network objects that might already be used in other parts of your configuration.
– Twice NAT—You identify a network object or network object group for both the real and mapped addresses. In this case, NAT is not a parameter of the network object; the network object or group is a parameter of the NAT configuration. The ability to use a network object group for the real address means that twice NAT is more scalable.
- How source and destination NAT is implemented.
– Network object NAT— Each rule can apply to either the source or destination of a packet. So two rules might be used, one for the source IP address, and one for the destination IP address. These two rules cannot be tied together to enforce a specific translation for a source/destination combination.
– Twice NAT—A single rule translates both the source and destination. A matching packet only matches the one rule, and further rules are not checked. Even if you do not configure the optional destination address for twice NAT, a matching packet still only matches one twice NAT rule. The source and destination are tied together, so you can enforce different translations depending on the source/destination combination. For example, sourceA/destinationA can have a different translation than sourceA/destinationB.
– Network object NAT—Automatically ordered in the NAT table.
– Twice NAT—Manually ordered in the NAT table (before or after network object NAT rules).
See the “NAT Rule Order” section for more information.
We recommend using network object NAT unless you need the extra features that twice NAT provides. Network object NAT is easier to configure, and might be more reliable for applications such as Voice over IP (VoIP). (For VoIP, because twice NAT is applicable only between two objects, you might see a failure in the translation of indirect addresses that do not belong to either of the objects.)
Information About Network Object NAT
All NAT rules that are configured as a parameter of a network object are considered to be network object NAT rules. Network object NAT is a quick and easy way to configure NAT for a network object, which can be a single IP address, a range of addresses, or a subnet.
After you configure the network object, you can then identify the mapped address for that object, either as an inline address or as another network object or network object group.
When a packet enters the ASA 1000V, both the source and destination IP addresses are checked against the network object NAT rules. The source and destination address in the packet can be translated by separate rules if separate matches are made. These rules are not tied to each other; different combinations of rules can be used depending on the traffic.
Because the rules are never paired, you cannot specify that sourceA/destinationA should have a different translation than sourceA/destinationB. Use twice NAT for that kind of functionality (twice NAT lets you identify the source and destination address in a single rule).
To start configuring network object NAT, see Chapter15, “Configuring Network Object NAT”
Information About Twice NAT
Twice NAT lets you identify both the source and destination address in a single rule. Specifying both the source and destination addresses lets you specify that sourceA/destinationA can have a different translation than sourceA/destinationB.
The destination address is optional. If you specify the destination address, you can either map it to itself (identity NAT), or you can map it to a different address. The destination mapping is always a static mapping.
Twice NAT also lets you use service objects for static NAT with port translation; network object NAT only accepts inline definition.
To start configuring twice NAT, see Chapter16, “Configuring Twice NAT”
Figure 11-14 shows a host on the 10.1.2.0/24 network accessing two different servers. When the host accesses the server at 184.108.40.206, the real address is translated to 220.127.116.11. When the host accesses the server at 18.104.22.168, the real address is translated to 22.214.171.124. (See the “Single Address for FTP, HTTP, and SMTP (Static NAT-with-Port-Translation)” section for details on how to configure this example.)
Figure 11-14 Twice NAT with Different Destination Addresses
Figure 11-15 shows the use of source and destination ports. The host on the 10.1.2.0/24 network accesses a single host for both web services and Telnet services. When the host accesses the server for web services, the real address is translated to 126.96.36.199. When the host accesses the same server for Telnet services, the real address is translated to 188.8.131.52.
Figure 11-15 Twice NAT with Different Destination Ports
Figure 11-16 shows a remote host connecting to a mapped host. The mapped host has a twice static NAT translation that translates the real address only for traffic to and from the 184.108.40.206/27 network. A translation does not exist for the 220.127.116.11/27 network, so the translated host cannot connect to that network, nor can a host on that network connect to the translated host.
Figure 11-16 Twice Static NAT with Destination Address Translation
NAT rules applied to the outside interface must refer to the outside Ethernet interface directly. For security policy purposes, the inside interface is divided up into separate security profiles. NAT rules applied to the inside interface must refer to a specific security profile, and not the inside interface directly.
Note Because security profile interfaces do not have IP addresses, you cannot use the security profile interface for interface PAT.
You can configure NAT between security profiles and the outside, but you cannot configure NAT between security profiles; because hosts defined by security profiles are all on the inside interface, traffic between security profiles does not pass through the ASA 1000V; they can reach each other directly or through the VSG if desired.
You can configure a NAT rule to apply to any interface (in other words, all interfaces), or you can identify specific real and mapped interfaces. You can also specify any interface for the real address, and a specific interface for the mapped address, or vice versa.
For example, you might want to specify any interface for the real address and specify the outside interface for the mapped address if you use the same private addresses on multiple interfaces, and you want to translate them all to the same global pool when accessing the outside (Figure 11-17).
Figure 11-17 Specifying Any Interface
Routing NAT Packets
The ASA 1000V needs to be the destination for any packets sent to the mapped address. The ASA also needs to determine the egress interface for translated packets. This section describes how the ASA 1000V handles accepting and delivering packets with NAT, and includes the following topics:
Mapped Addresses and Routing
When you translate the real address to a mapped address, the mapped address you choose determines how to configure routing, if necessary, for the mapped address.
See additional guidelines about mapped IP addresses in “Configuring Network Object NAT,” and Chapter16, “Configuring Twice NAT”
See the following mapped address types:
- Addresses on the same network as the mapped interface.
If you use addresses on the same network as the mapped interface, the ASA 1000V uses proxy ARP to answer any ARP requests for the mapped addresses, thus intercepting traffic destined for a mapped address. This solution simplifies routing because the ASA 1000V does not have to be the gateway for any additional networks. This solution is ideal if the outside network contains an adequate number of free addresses, a consideration if you are using a 1:1 translation like dynamic NAT or static NAT. Dynamic PAT greatly extends the number of translations you can use with a small number of addresses, so even if the available addresses on the outside network is small, this method can be used. For PAT, you can even use the IP address of the mapped interface.
Note If you configure the mapped interface to be any interface, and you specify a mapped address on the same network as one of the mapped interfaces, then if an ARP request for that mapped address comes in on a different interface, then you need to manually configure an ARP entry for that network on the ingress interface, specifying its MAC address (see Configuration > Device Management > Advanced > ARP > ARP Static Table). Typically, if you specify any interface for the mapped interface, then you use a unique network for the mapped addresses, so this situation would not occur.
- Addresses on a unique network.
If you need more addresses than are available on the mapped interface network, you can identify addresses on a different subnet. The upstream router needs a static route for the mapped addresses that points to the ASA 1000V. Alternatively, you can configure a static route on the ASA 1000V for the mapped addresses, and then redistribute the route using your routing protocol.
- The same address as the real address (identity NAT).
The default behavior for identity NAT has proxy ARP enabled, matching other static NAT rules. You can disable proxy ARP if desired. Note : You can also disable proxy ARP for regular static NAT if desired, in which case you need to be sure to have proper routes on the upstream router.
Normally for identity NAT, proxy ARP is not required, and in some cases can cause connectivity issues. For example, if you configure a broad identity NAT rule for “any” IP address, then leaving proxy ARP enabled can cause problems for hosts on the network directly-connected to the mapped interface. In this case, when a host on the mapped network wants to communicate with another host on the same network, then the address in the ARP request matches the NAT rule (which matches “any” address). The ASA 1000V will then proxy ARP for the address, even though the packet is not actually destined for the ASA 1000V. (Note that this problem occurs even if you have a twice NAT rule; although the NAT rule must match both the source and destination addresses, the proxy ARP decision is made only on the “source” address). If the ASA 1000V ARP response is received before the actual host ARP response, then traffic will be mistakenly sent to the ASA 1000V (see Figure 11-18).
Figure 11-18 Proxy ARP Problems with Identity NAT
In rare cases, you need proxy ARP for identity NAT; for example for virtual Telnet. When using AAA for network access, a host needs to authenticate with the ASA 1000V using a service like Telnet before any other traffic can pass. You can configure a virtual Telnet server on the ASA 1000V to provide the necessary login. When accessing the virtual Telnet address from the outside, you must configure an identity NAT rule for the address specifically for the proxy ARP functionality. Due to internal processes for virtual Telnet, proxy ARP lets the ASA 1000V keep traffic destined for the virtual Telnet address rather than send the traffic out the source interface according to the NAT rule. (See Figure 11-19).
Figure 11-19 Proxy ARP and Virtual Telnet
Determining the Egress Interface
The ASA 1000V determines the egress interface for a NAT packet in the following way:
- If you specify an optional interface, then the ASA 1000V uses the NAT configuration to determine the egress interface. For identity NAT, the default behavior is to use the NAT configuration, but you have the option to always use a route lookup instead.
- If you do not specify a specific interface, then the ASA 1000V uses a route lookup to determine the egress interface.
DNS and NAT
You might need to configure the ASA 1000V to modify DNS replies by replacing the address in the reply with an address that matches the NAT configuration. You can configure DNS modification when you configure each translation rule.
This feature rewrites the A record, or address record, in DNS replies that match a NAT rule. For DNS replies traversing from a mapped interface to any other interface, the A record is rewritten from the mapped value to the real value. Inversely, for DNS replies traversing from any interface to a mapped interface, the A record is rewritten from the real value to the mapped value.
Note If you configure a twice NAT rule, you cannot configure DNS modification if you specify the source address as well as the destination address. These kinds of rules can potentially have a different translation for a single address when going to A vs. B. Therefore, the ASA 1000V cannot accurately match the IP address inside the DNS reply to the correct twice NAT rule; the DNS reply does not contain information about which source/destination address combination was in the packet that prompted the DNS request.
Figure 11-20 shows a DNS server that is accessible from the outside interface. A server, ftp.cisco.com, is on the security profile QA interface. You configure the ASA 1000V to statically translate the ftp.cisco.com real address (10.1.3.14) to a mapped address (18.104.22.168) that is visible on the outside network. In this case, you want to enable DNS reply modification on this static rule so that QA users who have access to ftp.cisco.com using the real address receive the real address from the DNS server, and not the mapped address. When a QA host sends a DNS request for the address of ftp.cisco.com, the DNS server replies with the mapped address (22.214.171.124). The ASA 1000V refers to the static rule for the QA server and translates the address inside the DNS reply to 10.1.3.14. If you do not enable DNS reply modification, then the QA host attempts to send traffic to 126.96.36.199 instead of accessing ftp.cisco.com directly.
Figure 11-20 DNS Reply Modification, DNS Server on Outside
Figure 11-21 shows a web server and DNS server on the outside. The ASA 1000V has a static translation for the outside server. In this case, when a security profile QA user requests the address for ftp.cisco.com from the DNS server, the DNS server responds with the real address, 188.8.131.52. Because you want QA users to use the mapped address for ftp.cisco.com (10.1.2.56) you need to configure DNS reply modification for the static translation.
Figure 11-21 DNS Reply Modification, DNS Server on Host Network