Chapter 7: Using Address Translation

The Cisco Adaptive Security Appliance is frequently deployed at the border between a network using a private IP addressing scheme and the public Internet address space. To solve addressing issues when interconnecting these networks, the Cisco ASA supports Network Address Translation (NAT) and Port Address Translation (PAT).

This chapter discusses methods for configuring, verifying, and troubleshooting NAT and PAT deployed on a Cisco ASA.

“Do I Know This Already?” Quiz

The “Do I Know This Already?” quiz allows you to assess whether you should read this entire chapter thoroughly or jump to the “Exam Preparation Tasks” section. If you are in doubt about your answers to these questions or your own assessment of your knowledge of the topics, read the entire chapter. Table 7-1 lists the major headings in this chapter and their corresponding “Do I Know This Already?” quiz sections. You can find the answers in Appendix A, “Answers to the ‘Do I Know This Already?’ Quizzes.”

Table 7-1 “Do I Know This Already?” Section-to-Question Mapping

image


Caution

The goal of self-assessment is to gauge your mastery of the topics in this chapter. If you do not know the answer to a question or are only partially sure of the answer, you should mark that question as wrong for purposes of the self-assessment. Giving yourself credit for an answer you correctly guess skews your self-assessment results and might provide you with a false sense of security.


1. Which of the following is not a benefit of NAT?

a. Hides internal addressing and topology from hosts on the Internet

b. Allows multiple hosts to share the same globally unique IP address

c. Mitigates global address depletion

d. Allows change of ISP without internal re-addressing

e. All of the above are benefits of NAT

2. Which of the following is true when NAT control is enabled?

a. Translation rules are not required, but will be performed if configured.

b. Configuration of translation rules is not permitted.

c. Translation rules are required for all transit traffic.

d. Translation rules are required only for sessions initiated on a higher-security interface, bound for a lower-security interface.

3. Your ASA is configured for dynamic inside PAT. Hosts on the 10.0.0.0/24 internal network share global IP address 209.165.200.254. As hosts initiate TCP connections to external servers, what happens?

a. The source IP address is translated to 209.165.200.254. The source port is retained, unless that port is already in use, in which case it is translated.

b. The source IP address is translated to 209.165.200.254. If the original source port is 1024 or greater, it is translated to a seemingly random port number in the range 1024–65535.

c. The source IP address is translated to 209.165.200.254. Each host is then allocated ten port numbers for its use. These ports are assigned to subsequent connections from the source host, and return to availability as sessions are terminated.

d. The described configuration is invalid.

4. An Internet-based host initiates a connection to a web server, using IP address 209.165.200.228, which is a translated address for a server on the DMZ network. Is the translation performed with inside or outside static NAT?

a. Inside static NAT

b. Outside static NAT

5. When should inside static PAT be used? (Choose two.)

a. For server systems that require only inbound connectivity over NAT

b. For server systems that require bidirectional connectivity over NAT

c. When a server listens for connections on both TCP and UDP ports

d. When a single global IP address is shared by many internal servers, each supporting applications on different listening ports

e. For a group of client systems that must appear to come from a single IP address when communicating with an external vendor application host

6. An application embeds IP addresses at the application layer, and uses end-to-end encryption. Which “flavor” of address translation should be used in this situation?

a. Dynamic inside NAT

b. Static inside policy NAT

c. Dynamic inside policy NAT

d. Static outside NAT

e. NAT bypass

7. Where in Cisco ASDM do you enable NAT control?

a. Configuration > Firewall > NAT Rules

b. Configuration > Firewall > Advanced

c. Configuration > Device Setup > Advanced

d. Configuration > Device Setup > Interfaces > NAT Rules

8. Which of the following commands changes the translation slot idle timer value to 1 hour?

a. translation idle timer 01:00:00

b. xlate idle timer 01:00:00

c. timeout xlate 01:00:00

d. timer xlate 01:00:00

e. None of these answers are correct.

9. Given the following partial ASA configuration, with all translation slots cleared, to which address will host 10.0.0.101 be translated when initiating a session to web server 172.16.0.5 on the DMZ network?

access-list NO_NAT permit ip host 10.0.0.101 172.16.0.32 255.255.255.224
nat-control
nat (inside) 5 access-list NO_NAT
nat (inside) 1 10.0.0.0 255.255.255.0 tcp 0 0 udp 0
nat (inside) 2 0.0.0.0 0.0.0.0 tcp 0 0 udp 0
global (outside) 1 209.165.200.235-209.165.200.254 netmask 255.255.255.224
global (DMZ) 2 172.16.0.101-172.16.0.254 netmask 255.255.255.0
global (DMZ) 5 interface

a. 209.165.200.235

b. 172.16.0.101

c. 172.16.0.1 (the ASA DMZ interface IP)

d. None of these answers are correct because the translation attempt will fail.

10. You are tasked to configure dynamic inside PAT for hosts on the inside network when they communicate with the DMZ network. The DMZ network is 172.16.0.0/24. The PAT address will be 172.16.0.254. Which subnet mask should you enter in the NAT Rules configuration window?

a. 255.255.255.0

b. 255.255.255.255

c. 0.0.0.255

d. 0.0.0.0

e. None of the answers are correct. There is no subnet mask field in the NAT Rules configuration window.

11. Given the following partial ASA configuration, with all translation slots cleared, to which source address and source port will host 10.0.0.101 be translated when initiating a session with web server 172.16.0.5 on the DMZ, with original source port 49151?

nat (inside) 1 10.0.0.0 255.255.255.0 tcp 0 0 udp 0
global (outside) 1 209.165.200.254 netmask 255.255.255.255
global (DMZ) 1 interface

a. 49151

b. 65535

c. A seemingly random port, 1024 or higher, based on an internal ASA algorithm

d. 1024

12. You are tasked to configure dynamic inside PAT for hosts on the inside interface when communicating with external hosts (through the outside interface). Due to a lack of IP addresses, you will use the IP address of the ASA’s outside interface, 209.165.200.226, as the PAT address. Which of the following configurations is correct?

a. nat (inside) 5 0.0.0.0 0.0.0.0
global (outside) 5 209.165.200.226

b. nat (inside) 1 10.0.0.0 255.255.255.0
global (outside) 1 209.165.200.226

c. nat (inside) 0 10.0.0.0 255.255.255.0
global (outside) 0 interface

d. nat (inside) 300 10.0.0.0 255.255.255.0
global (outside) 300 interface

e. None of the answers provide a valid configuration.

13. You see the following in the output of the show xlate detail command:

TCP PAT from inside:10.0.0.101/49274 to outside
(POLICY_NAT_ACL):209.165.200.134/17637 flags ri

What is the meaning of the r and i flags?

a. r means sequence number randomization is enabled, and i means inside NAT is being used.

b. r means PAT is being used, and i means dynamic NAT is being used.

c. r means sequence number randomization is enabled, and i means identity NAT is being used.

d. r means PAT is being used, and i means identity NAT is being used.

14. You have a web server on the DMZ network, address 172.16.0.5. You are tasked with granting access to this server to all Internet-based hosts, using global address 209.165.200.228. Which of the following shows the correct command or commands to accomplish this, assuming access lists are already configured to permit this traffic?

a. nat (DMZ) 4 172.16.0.5 255.255.255.255
global (outside) 4 209.165.200.228 netmask 255.255.255.255

b. static (DMZ,outside) 172.16.0.5 209.165.200.228 netmask 255.255.255.255

c. access-list WEB permit tcp any host 209.165.200.228 eq www
static (DMZ,outside) access-list WEB

d. static (DMZ,outside) 209.165.200.228 172.16.0.5 netmask 255.255.255.255

15. The DMZ interface has a higher security level than the PartnerNet interface. Given the configuration that follows, which address will server 172.16.0.55 appear as when communicating with hosts on the PartnerNet network?

static (DMZ,PartnerNet) 172.18.10.64 172.16.0.32 netmask 255.255.255.224

a. 172.18.10.55

b. 172.16.0.55

c. 172.18.10.87

d. 172.18.0.87

e. None of these answers are correct.

16. You have an SMTP email server on the DMZ, address 172.16.0.20. This host must be reachable from the Internet using port 25, and from the PartnerNet (172.18.10.0/24) using port 2525. Additionally, a web server on the DMZ, address 172.16.0.5, shares the global IP address 209.165.200.235 with the email server, for the outside interface. Which of the following configurations would work?

a. static (DMZ,outside) tcp 209.165.200.235 25 172.16.0.20 25
static (DMZ,outside) tcp 209.165.200.235 80 172.16.0.5 80
static (DMZ,PartnerNet) tcp 172.18.10.20 2525 172.16.0.20 25

b. static (DMZ,outside) 209.165.200.235 25 172.16.0.20 25
static (DMZ,outside) 209.165.200.235 80 172.16.0.5 80
static (DMZ,PartnerNet) 172.18.10.20 2525 172.16.0.20 25

c. static (DMZ,outside) tcp 172.16.0.20 25 209.165.200.235 25
static (DMZ,outside) tcp 172.16.0.5 80 209.165.200.235 80
static (DMZ,PartnerNet) tcp 172.16.0.20 25 172.18.10.20 2525

d. static (DMZ,outside) tcp 209.165.200.235 2525 172.16.0.20 25
static (DMZ,outside) tcp 209.165.200.235 80 172.16.0.5 80
static (DMZ,PartnetNet) tcp 172.18.10.20 25 172.16.0.20 25

17. Your network is connected via VPN to a vendor network. You have an application server on the inside segment that requires outbound-only access to a database server on the vendor network. Due to a routing conflict, the server must appear as an alternate address when communicating with the vendor site. Which NAT “flavor” is most appropriate for this scenario?

a. Dynamic inside NAT

b. Static inside NAT

c. Dynamic inside policy NAT

d. NAT bypass

e. Static inside policy PAT

f. Static outside policy NAT

18. When using static inside policy NAT, hosts on less secure interfaces are able to initiate communication with hosts on more secure interfaces that are subject to translation. True or False?

a. True

b. False

19. Which of the following creates dynamic identity translation slots in the translation table (where local and global addresses are the same) when hosts on a more secure interface communicate with hosts on less secure interfaces?

a. Dynamic inside NAT

b. Static identity NAT

c. NAT bypass

d. Dynamic identity NAT

20. Your inside network is 10.0.0.0/24. Your DMZ network is 172.16.0.0/24. You want to configure hosts on the inside network to reach the DMZ without being translated, while still maintaining the ability to communicate with the Internet through use of address translation. Which of the following configuration samples accomplishes this?

a. access-list NO_NAT permit ip 10.0.0.0 255.255.255.0 172.16.0.0 255.255.255.0
nat (inside) 1 access-list NO_NAT
nat (inside) 1 10.0.0.0 255.255.255.0
global (outside) 1 209.165.200.235-209.165.200.254 netmask 255.255.255.224

b. access-list NO_NAT permit ip 10.0.0.0/24 172.16.0.0/24
nat (inside) 1 10.0.0.0/24
nat (inside) 0 access-list NO_NAT
global (outside) 1 209.165.200.235-209.165.200.254/27

c. access-list NO_NAT permit ip 10.0.0.0 255.255.255.0 172.16.0.0 255.255.255.0
nat (inside) 1 10.0.0.0 255.255.255.0
nat (inside) 0 access-list NO_NAT
global (outside) 1 209.165.200.235-209.165.200.254 netmask 255.255.255.224

d. access-list NO_NAT permit ip 10.0.0.0 255.255.0.0 172.16.0.0 255.255.255.0
nat (inside) 1 10.0.0.0 255.255.255.0
nat (inside) 0 access-list NO_NAT
global (outside) 1 209.165.200.235-209.165.200.254 netmask 255.255.255.224

21. Hosts on the inside network need to reach a web server on the DMZ. However, they use an Internet-based DNS server for name resolution. How would you configure the ASA to ensure that these connections are successful?

a. static (DMZ,outside) 209.165.200.228 172.16.0.5 dns

b. nat (inside) 1 10.0.0.0 255.255.255.0 dns
global (outside) 1 interface

c. static (DMZ,inside) 172.16.0.5 172.16.0.5 dns

d. None of the answers are correct.

22. Hosts on the Internet need to reach a web server on the DMZ. Your ASA contains the following command:

static (DMZ,outside) 209.165.200.228 172.16.0.5 tcp 0 0 udp 0

When configuring an access list inbound on the outside interface, to which destination address should you be allowing access?

a. 172.16.0.5

b. 209.165.200.228

Foundation Topics

This chapter describes how IP addresses can be altered or translated as packets move through an ASA. The various types of network address translation (NAT) and port address translation (PAT) are covered.

NAT performs the translation of source and/or destination IP addresses in packets traversing the ASA. PAT, in addition to translating IP addresses, translates source port numbers in TCP or UDP packets, thus allowing many-to-one translation of source IP addresses. This allows numerous internal hosts to share a single public IP address when communicating with external networks.

Understanding How NAT Works

Network Address Translation (NAT) was developed to overcome IP addressing problems that occurred when the ARPANet, which interconnected only a few dozen large institutions, became the Internet, which had the ability to interconnect networks and computers globally, leading to massive growth. There simply were not enough addresses available in the originally designed IP addressing scheme to accommodate universal connectivity, especially given the manner in which addresses were originally assigned. Therefore, a system of “private” IP addresses was developed, first in RFC 1597, which was then superseded by the better-known RFC 1918, which allows multiple networks around the world to deploy the exact same IP addresses for addresses that require only local uniqueness. This eliminates the need to maintain globally unique addresses for every connected host worldwide.

Because private IP addresses are intended for local use only and are considered “nonroutable” on the public Internet, NAT is required to translate these private (local) IP addresses to public (global), routable addresses when hosts on a private network need to communicate with hosts outside of that private network.

Additionally, because many organizations can deploy the same private IP addresses, due to local significance, NAT is required if hosts on these networks with overlapping addresses need to communicate with each other.

NAT thus provides the following benefits:

• NAT mitigates public IP address depletion because, when used in combination with PAT, many private hosts can share a single public IP address, while using unique private addresses internally.

image

• NAT allows an organization to undergo a change of Internet service provider (ISP), with provider-dependent public IP addresses, without having to change its internal, private addressing plan.

• As a security measure, NAT hides the internal IP addressing scheme and network topology from the public Internet, even while it allows interconnectivity.

In its simplest form, for an ASA to perform NAT or PAT, four pieces of information are required:

• Original source IP address (and port) in the packet

• Interface where the original packet enters the ASA (ingress interface)

• Interface where the packet will exit the ASA (egress interface)

• Translated address (and, optionally, port) to insert into the packet

Understanding this concept is important because these four pieces of information are required in each of the many variations of NAT and PAT. If any of these four items is unknown, an ASA cannot perform address translation. Also, these items are all recorded in the translation table (xlate table) maintained by the ASA for tracking address translation that it is performing.

Figure 7-1 shows a basic example of NAT implementation. An internal host, with private IP address 10.0.0.101, needs to communicate with a web server on the Internet.

Figure 7-1 Basic Address Translation Example

image

When the NAT-enabled Cisco ASA in Figure 7-1 receives a packet from the internal host, it translates the source IP address of the packet before forwarding the packet to the Internet. This is necessary because the private IP address assigned to the host is not allowed to be routed through the Internet. In the figure, the host’s address is translated to the public IP address 209.165.200.235. When a host on the Internet receives this packet, it sends its reply to 209.165.200.235 as the destination IP address. This packet arrives at the Cisco ASA, which consults its address translation table and, finding the entry related to the translation being performed, translates this destination IP address back to 10.0.0.101 before forwarding it onto the internal network to the originating host.

So, in the example shown in Figure 7-1, the four required pieces of information are

• 10.0.0.101: Original source IP address

• inside: Ingress interface

• outside: Egress interface (determined by routing decision)

• 209.165.200.235: Translated source IP address

Enforcing NAT

The basic example of NAT just detailed stated that a “NAT-enabled” ASA received packets. So, what makes an ASA NAT-enabled? Simply put, any ASA that is configured to perform NAT is NAT-enabled. However, if an organization uses RFC 1918 private addresses, NAT is required to permit communication with external networks. You must therefore be able to distinguish between performing NAT and enforcing NAT. As already stated, any ASA configured to perform NAT will do so. What, then, does it mean to configure an ASA to enforce NAT?

Prior to OS version 7.0, there was no way for a PIX firewall to forward packets from a higher-security interface to a lower-security interface (“outbound” traffic) without being configured with rules for address translation. Thus, it was a requirement of passing traffic that all outbound packets be matched to a translation rule (even if such a rule were to exempt a packet from translation). The use of NAT was thus enforced, not merely permitted. Starting with OS version 7.0, and the introduction of the Cisco ASA, an ASA does not enforce the use of NAT, by default.

It is important to note that if an organization’s network already contains enough globally unique IP addresses to accommodate all internal hosts, NAT is not necessary to permit that network to intercommunicate with the rest of the world. The internal hosts could be configured with globally unique addresses, and the ASA could simply forward traffic without any address translation. However, even in such a case, some organizations choose to assign private, RFC 1918 addresses to their internal network, especially if their IP addresses were allocated to them by an ISP rather than registered to them directly. If such an organization decides to change ISPs, it does not need to re-address its entire internal network, which it would otherwise have to do if it had allocated the globally unique IPs directly to internal hosts. It is important to remember the security implications of NAT (hiding internal address and topology information) before making such a decision.

Even if an organization used private IP addresses, it would not be necessary to perform NAT on the ASA. The ASA would simply forward packets with the original addresses intact. The assumption would be that another inline device would perform NAT. Otherwise, the packets would be dropped as nonroutable traffic when they entered the Internet space.

With OS versions 7 and later, it is still possible to enforce the use of NAT. Essentially, the ASA functions much as a pre-OS version 7 firewall would, and drops any outbound packets not addressed by configured translation rules. Enforcing NAT is considered a security enhancement, as it can create another layer of access control (dropping packets that have no translation rule), and is thus widely used, even at the cost of increased configuration complexity.

The function used to enforce NAT is known as NAT control, and its configuration is covered later in this chapter alongside the configuration of NAT rules.

Address Translation Deployment Options

As previously mentioned, there are many variations of address translation that can be performed by a Cisco ASA. One of the deployment options, just covered, is whether to enforce the use of NAT as a security enhancement.

If you are using NAT, there are many further options to consider, such as whether to perform fixed or temporary address translation. Fixed translation, where an original address is permanently assigned the translated IP address, is known as static NAT. Temporary translation, where an original host is assigned an address from an available pool, and that address is returned to the pool after a configurable idle time, is known as dynamic NAT. Static NAT is typically used with servers, and dynamic NAT is typically used with client hosts.

There are two “directions” for NAT usage, known as inside NAT and outside NAT. If the packets arriving at the ASA from a host subject to translation ingress an interface with a higher security level than the interface they egress, the address translation performed is known as inside NAT. Conversely, if packets arriving from a host subject to translation ingress an interface with a lower security level than the interface they egress, the address translation performed is known as outside NAT. Recall that the assigned security level of an interface determines whether that interface, and networks reachable through that interface, is considered more or less secure relative to the other interface involved in a traffic flow.


Note

It is always important to remember which host is subject to translation. For instance, packets originating on the Internet and destined for an internal web server do not constitute the use of outside NAT. It is not the originating host that is subject to address translation, but rather the internal web server. Thus, packets from the host subject to translation (the internal web server) ingress the ASA on an interface that has a higher security level than the interface they egress, and the translation performed is inside NAT.


The implementation of NAT or PAT can be further enhanced by making it conditional (based on a policy). Generally, the need for this arises based on access restrictions at the destination host, but there are many reasons it may be necessary in practice. Such implementation is accomplished by using an access control list (ACL) to define the policy. Traffic flows defined as permitted in the ACL become those subject to the policy NAT implementation.

Thus, when performing NAT, you have the choices of dynamic inside NAT, static inside NAT, dynamic outside NAT, and static outside NAT. Each of these deployment options can further be subdivided into policy vs. nonpolicy options.

A final option to consider is to exempt certain traffic from NAT. If NAT control is not enabled (NAT is not being enforced), this is unnecessary. However, if NAT control is enabled, and there are traffic flows that you do not want to undergo address translation, you must configure NAT exemption rules.

NAT Versus PAT

It is important to understand the difference in implementation between NAT and PAT so that you understand when each choice is appropriate for your particular network environment.

When you use inside NAT, only the source IP address of the internal host is translated, and a one-to-one mapping is made between the original (local) IP address and the translated (global) address assigned to the host. The global address can be assigned in either a static (fixed and permanent) or dynamic (from a pool and temporary) manner. If there are not enough global IP addresses to support all internal hosts, some hosts will not be able to communicate through the ASA.

Figure 7-2 illustrates the use of NAT with an example of inside NAT. Recall that inside NAT means that traffic from the host subject to translation ingresses the ASA on a more secure interface than it egresses the ASA. In the figure, two hosts connected to the inside interface of the ASA both need to communicate with destinations on the Internet.

Figure 7-2 Dynamic Inside NAT Scenario

image

In Figure 7-2, hosts on the internal 10.0.0.0/24 network share a pool of global addresses, 209.165.200.235-254, from which addresses are dynamically allocated to hosts as they make connections, and to which addresses are returned after an idle period. Host 10.0.0.101 is assigned the first address from the pool, 209.165.200.235, when it makes the first outbound connection. Host 10.0.0.102, upon making its connection, is assigned the next address from the pool, 209.165.200.236. This is merely an example, although it also illustrates how the ASA allocated pool addresses prior to OS version 8.0(3). As of version 8.0(3), a random address is allocated from the pool.


Note

The example deliberately uses a pool that is not congruent with the boundaries of subnetting, such as 209.165.200.240/28 would be. Although the command that creates a global pool optionally uses a subnet mask parameter, it does not perform subnetting of the network attached to the ASA. This is an important concept for you to understand to maximize the efficiency of address allocation within your own network environment.


Figure 7-3 illustrates the use of NAT with an example of inside PAT. When you use inside NAT, only the source IP address of the internal host is translated, and a one-to-one mapping is made between the original (local) IP address and the translated (global) address assigned to the host. With PAT, however, both the source IP address and source port (for TCP and UDP packets) are translated, which creates a many-to-one mapping, with multiple internal hosts sharing a single global IP address, and each of their TCP or UDP connections being assigned a unique port number, tracked by the ASA for the duration of the connection. This allows for maximum efficiency in conserving global IP addresses, but is not compatible with all applications.

Figure 7-3 Dynamic Inside PAT Scenario

image

In Figure 7-3, hosts on the internal 10.0.0.0/24 network share a single global address, 209.165.200.254. When host 10.0.0.101 initiates a TCP connection to a web server on the Internet, it is assigned the 209.165.200.254 address, and its original TCP source port of 49501 is translated to port 46224. When host 10.0.0.102 makes its connection to the same web server, it also uses global IP address 209.165.200.254, and is assigned the translated port 27645. Subsequent connections from any host on the 10.0.0.0/24 network (including .101 and .102) are assigned seemingly random source port numbers, based on an internal ASA algorithm.

Input Parameters

With these considerations in mind, we can now more fully define the overall input parameters that you will need to consider in determining how NAT or PAT functionality needs to be defined for your particular environment.

Table 7-2 lists and describes input parameters. These are parameters that you must understand and fully enumerate to correctly deploy address translation rules for your environment.

Table 7-2 Address Translation Input Parameters

image

It is important to remember that the terms “local” and “global,” when related to NAT configuration on a Cisco ASA, really equate to “original” and “translated,” respectively, because in the case of outside NAT, the local address is frequently that of a foreign network, and the global addresses to which the local addresses are translated are usually from an internal network.

Regarding system roles, each system can generally be defined as either a client (a system that only initiates connections) or a server (a system that accepts incoming connections, and can also initiate outgoing connections). Client hosts can generally operate successfully through dynamic NAT, but servers require static NAT, as the IP addresses to which their clients need to connect must be predictable and fixed.

It is important to know if your organization uses applications that do not work with NAT or PAT. Examples of such applications are presented later in this chapter, in the “NAT Exemption” section.

Deployment Choices

The decision of whether to use inside or outside NAT, policy or nonpolicy NAT, or static or dynamic NAT may at first seem very complex. Table 7-3 presents the various deployment choices, along with the criteria that normally make such a choice appropriate.

Table 7-3 NAT Deployment Choices and Criteria

image

image

On a single Cisco ASA, it is possible to deploy a combination of all the options in Table 7-3, depending on your needs.

When NAT is combined with access controls, on a Cisco ASA running an OS version prior to 8.3, NAT configuration necessarily influences the configuration of interface ACLs, AAA rules, and Modular Policy Framework (MPF) rules (each of these topics is covered in other chapters).

NAT Exemption

The last deployment choice for NAT is when not to use it. Remember, of course, that if NAT control is not enabled, then all traffic is exempted from NAT. That is, if NAT rules are configured, they are implemented, but traffic that is not subject to such rules is forwarded without the requirement for NAT (NAT is not enforced).

The following is a list of situations that would require you to exempt certain traffic from NAT on an ASA that otherwise enforces NAT:

• Do not use NAT or PAT with applications that embed IP addresses on the application layer and use end-to-end encryption. With encrypted traffic, the Cisco ASA cannot translate embedded addresses and allow such applications to work properly across NAT.

• Do not use NAT or PAT with applications that authenticate entire packets (such as IPsec Authentication Header (AH) or Border Gateway Protocol (BGP)). When a packet hash value is calculated, and then addresses and/or port numbers are translated later, the verification of the hash at the other end of the communication will fail, and the packet will be dropped.

• Do not use NAT or PAT with applications that establish additional dynamic sessions, and for which the ASA does not support protocol-specific inspection rules. Also, if the application uses an encrypted control channel, the ASA will not be able to inspect the packet contents and perform modifications allowing the application to work properly across NAT/PAT.

There are other situations in which you will typically choose to exempt traffic from NAT/PAT, but in such cases, it is a choice, whereas the list just presented shows when it is a requirement. The most frequent examples of this are traffic that will traverse a VPN connection (for more information on VPNs, consult the CCNP Security VPN Official Certification Guide), or traffic between two internal networks, such as from the inside network to the DMZ network. Although such traffic traverses the ASA, the private addresses in use are never seen in an external environment where they would be considered nonroutable, so address translation is not necessary.

Configuring NAT Control

As previously mentioned, NAT control is a feature that configures the ASA to enforce NAT usage—that is, to require a translation rule for each host on a more secure interface when it communicates with hosts on lower-security interfaces (NAT exemption is an acceptable translation rule). NAT control is disabled by default.

image

When NAT control is enabled and a host on a more secure interface attempts communication through the ASA to a less secure interface, the ASA first checks to see if there is an existing entry in the translation table for the host in question. Such an entry would exist if the host had previously communicated through the ASA, there was a configured translation rule for the host, and a translation slot had been created for that host already and had not yet expired due to the xlate timeout value being exceeded. If an entry exists, the ASA performs the same translation for the host as previously.

If there is not an existing entry, one will be created if a translation rule is configured for the host. If there is not an existing entry, and no translation rule exists to create one, the traffic is dropped.


Note

NAT is not required between same security level interfaces even if NAT control is enabled (as long as the ASA is configured to permit traffic between same security level interfaces). You can configure NAT if desired, and the ASA will perform address translation for the traffic passing between the same security level interfaces.


Figure 7-4 demonstrates how to enable NAT control (navigate to Configuration > Firewall > NAT Rules). NAT control is a global feature and is either on or off for the entire ASA, not specific interfaces or translation rules. However, it is configured in the NAT Rules window of the device configuration.

Figure 7-4 Enabling NAT Control

image

At the bottom of the NAT Rules window is a check box that is checked by default. To enable NAT control, uncheck the Enable Traffic Through the Firewall Without Address Translation check box and click Apply.

The CLI command generated by the change made is as follows:

nat-control

If you are configuring the ASA from the CLI, you can enter this command directly in global configuration mode.

Configuring Dynamic Inside NAT

Dynamic inside NAT creates a temporary translation entry (slot) in the translation table when a host on a more secure interface sends traffic through the ASA to a less secure interface. Each local (original) address configured to use NAT on the ingress interface is translated to a global (translated) address selected from a configured pool on the egress interface. The translation is kept in place until a configurable idle timer expires (3 hours by default) or the translation slot is manually cleared by an administrator. Because these translations are dynamic, the same host, initiating connections at different times, is frequently translated to different global addresses.

image

Dynamic inside NAT should generally be used for client hosts that need outbound connectivity only. This is because, when using dynamic inside NAT, hosts on less secure interfaces cannot initiate connections to hosts on more secure interfaces that are configured to use dynamic NAT translation, unless the translation slot has already been created by outbound packets, and the interface access list on the less secure interface permits such a connection (interface access lists are discussed in Chapter 8, “Controlling Access Through the ASA”). Additionally, as previously mentioned, servers must have addresses that are fixed and predictable in order for their clients to connect to them successfully, so dynamic NAT is not an option for service-providing hosts.

Recall the four pieces of information necessary for an ASA to perform NAT:

• Original source IP address (and port) in the packet

• Interface where the original packet enters the ASA (ingress interface)

• Interface where the packet will exit the ASA (egress interface)

• Translated address (and, optionally, port) to insert into the packet

To configure an ASA to perform dynamic inside NAT, you must specify these four pieces of information. Also, you can optionally alter the default global translation slot idle timeout value (known as the xlate timer).

In demonstrating how to configure dynamic inside NAT, we will use the example introduced earlier. Figure 7-5 shows the scenario. Hosts on the 10.0.0.0/24 network, which is connected to the ASA inside interface, will share a pool of global addresses, 209.165.200.235-254, configured on the ASA outside interface. Additionally, this example will assume that the xlate timeout value has been adjusted from 3 hours to 1 hour.

Figure 7-5 Dynamic Inside NAT Scenario

image

The configuration scenario assumes that routing between all involved networks has been properly configured, and that any access lists present on the ASA permit communication between the inside network and the Internet.

To configure the scenario in Figure 7-5, first navigate to Configuration > Firewall > NAT Rules. Click Add to open a drop-down menu, and choose Add Dynamic NAT Rule. Figure 7-6 shows the resulting Add Dynamic NAT Rule dialog box, in which you configure the specifics of the new NAT rule.

Figure 7-6 Adding a Dynamic NAT Rule

image

From the Interface drop-down list, select the ingress interface for this NAT rule. In Figure 7-6, the inside interface is selected. Next, in the Source field, enter the local IP address or address range that will be subject to this NAT rule. Optionally, click the ellipses (...) button to choose an IP address or range that has already been defined within Cisco ASDM. If entered manually, define the address and subnet mask using prefix and length notation. Figure 7-6 shows the 10.0.0.0/24 address range being specified.


Note

If you enter an IP address with no mask, Cisco ASDM treats it as a host address, even if it ends with a 0 in the final octet.



Note

Although it is possible to define a source range of 0.0.0.0/0 (any IP address), this is poor security practice, as it would perform NAT translation for any source IP, whether or not that IP was a valid address in the range reachable through the ingress interface. This would only be overcome if you enable reverse-path verification with the ip verify reverse-path interface intf_name command.


Finally, in the Translated area of the dialog box, any previously defined global pools are listed. You can select one to which you want to bind this NAT rule, and click OK. Because, in this example, only the system default NAT exemption rules are currently known, click the Manage button to begin the configuration of a new global pool. This will open the Manage Global Pool dialog box.

The Manage Global Pool dialog box allows you to select or edit a global address pool that has already been defined, or create a new global address pool. To create a new global pool, click the Add button, which opens the Add Global Address Pool dialog box, shown in Figure 7-7. This dialog box allows you to create address translation pools and bind them to ASA interfaces.

Figure 7-7 Creating a Global Address Pool

image

When you create a global pool, you must bind it to a particular ASA interface. This is because the same originating hosts that are subject to a NAT rule might, at any given time, be in communication with hosts reachable through different lower-security interfaces. Recall that all translation rules require an original address, an ingress interface, a translated address, and an egress interface in order to completely define an address translation rule. You have already completed the definition of the first two factors—the creation of the global address pool defines the latter two.

To select an interface where the global pool will be used, from the Interface drop-down list, select the interface where traffic using this pool will egress the ASA. In Figure 7-7, the outside interface is selected.

Next, enter a number between 1 and 2147483647 in the Pool ID field. Cisco ASDM and the ASA use this number to bind the local (original) addresses previously specified to this global pool. In Figure 7-7, a pool ID of 1 is used.

In the IP Addresses to Add area, click the Range radio button. The other options in this section are not used for dynamic NAT. Enter the first IP address for the pool in the Starting IP Address field. Enter the last IP address for the pool in the Ending IP Address field. In Figure 7-7, the pool range is defined as 209.165.200.235 through 209.165.200.254. When this pool of 20 addresses is exhausted, no further translations will occur until addresses are returned to the pool. Any outbound packets requiring translation in such a situation would be dropped.

Optionally, you might enter a network mask for the range defined. If the global pool range is part of the subnet to which the egress interface is connected (as it is in our example), you should enter the same mask configured on the interface itself. While not strictly necessary, this can be helpful when referring to the configuration. Because the IP address on the interface in this example is 209.165.200.226 with a 255.255.255.224 mask, the mask entered in Figure 7-7 is 255.255.255.224. Remember that this mask is for reference only and does not perform any subnetting function.


Note

You can specify more than one range of addresses with the same pool ID on the same interface. These ranges will be added together to form a single pool consisting of multiple ranges. Also, any addresses that are routed to the selected interface are acceptable, even if they are from different subnets than the ASA interface itself. For instance, the outside interface of our ASA is on the 209.165.200.224/27 subnet. However, assuming that the perimeter router also routed the 209.165.201.0/27 subnet to the ASA, you could configure all or any part of that address range as a global pool on the outside interface. Note that in such a case, it is not even necessary to “reserve out” the .0 and .31 addresses, which would normally be considered unusable because they would represent the network identifier and the local broadcast address. You could use all 32 addresses in the range for the global address pool.


To complete the definition of the new global address pool, click Add to move the defined range into the Addresses Pool list. Then, click OK in this dialog box, and click OK again in the Manage Global Pool dialog box. This returns you to the Add Dynamic NAT Rule dialog box. Figure 7-8 shows this, with the newly created global address pool now present in the Translated area of the dialog box.

Figure 7-8 Binding a Global Pool to a NAT Rule

image

The final step to completing the definition of a NAT rule is to bind the original address and ingress interface to a particular translation pool defined on the egress interface for this traffic. You have defined as eligible for translation original addresses of 10.0.0.0/24, which ingress the inside interface, and have created a global pool of 209.165.200.235-254 to be used when the outside interface is the egress interface. To bind these together, select the newly configured pool by clicking it, as shown in Figure 7-8, and then click the OK button.


Tip

When you are configuring from the CLI, where changes are immediate (whereas clicking Apply is necessary in Cisco ASDM), it is advisable to create the global pool first, and then enter the nat command, because as soon as you enter the nat command, eligible hosts may begin to attempt connections. When the ASA attempts to match these hosts to a global pool and finds none, it will drop the packets. Also, it will record the fact that the attempting host has no translation rule, and drop packets for the duration of the xlate timeout value, unless an administrator manually clears the translation slot.


The final step in this scenario is to adjust the global translation idle timer (the xlate timeout value) from the default of 3 hours to 1 hour. To do this, navigate to Configuration > Firewall > Advanced > Global Timeouts. Figure 7-9 shows the Global Timeouts window. There are many global timeout values tracked by a Cisco ASA.

Figure 7-9 Changing the xlate Timeout

image

As shown Figure 7-9, to change the xlate (translation slot) timeout value, check the Translation Slot check box. The field will no longer be dimmed. Enter a new timeout value. The figure shows the new timeout value being set as 1 hour.

Click OK to save the changes made in this window. Finally, click Apply to send the configuration changes to your ASA.

The CLI commands generated by the changes made are as follows:

nat (inside) 1 10.0.0.0 255.255.255.0
global (outside) 1 209.165.200.235-209.165.200.254 netmask 255.255.255.224
timeout xlate 1:00:00

If you are configuring the ASA from the CLI, you can enter these commands directly in global configuration mode. Note that two commands exist to define dynamic NAT, and are associated with each other through the use of the same NAT ID number, which is 1 in this example.

Any individual host can match only one NAT rule for any given connection. The practical significance of this is that any given original address can be bound to only one dynamic NAT ID at a time. So, in the example, a host on the 10.0.0.0/24 subnet would be bound to NAT ID 1, regardless of the egress interface. For example, if a host on the inside subnet were to communicate with the DMZ subnet, and such connections were dynamically translated, we would need a global address pool, with a NAT ID of 1, on the DMZ interface for the internal host to be successfully translated. This is perfectly acceptable—nothing implies that a NAT ID can be used on only one interface or must be unique in any way. Examples of multiple interfaces with NAT appear in the next section.

image

Configuring Dynamic Inside PAT

Dynamic inside NAT creates one-to-one translations of local IP addresses to global IP addresses. Dynamic inside PAT, by contrast, creates many-to-one translations, allowing numerous local IP addresses to share a single global IP address. It does so by creating a temporary translation of both the original IP address and the original source port number to a global IP address and unique global port number, for each translated session (the term session is used to indicate a unique, bidirectional communication and therefore is used even when referring to UDP, which is connectionless). These translations are created and added to the translation table for each outbound TCP or UDP session requiring PAT, and are deleted and removed from the table when the OSI Layer 4 session closes. The port numbers are assigned based on an internal algorithm and will appear random.

image


Note

Older versions of the OS on the Cisco PIX Firewall and ASA assigned PAT port numbers sequentially, beginning with 1024 and moving upward, for host connections initiated from port numbers 1024 and higher.


Because each OSI Layer 4 session uses a separate translation slot, the size of the translation table can grow very large in a production network.

To provide a global IP address for PAT, you can define an available IP address, or you can configure the use of the ASA’s IP address on the egress interface. Using the ASA interface IP is particularly useful in environments where you are provided only one IP address, usually dynamically assigned, by an ISP, but it is not limited to such instances.

Like dynamic NAT, dynamic PAT is typically used for client hosts that need outbound connectivity only, and when there are not enough global IP addresses available to assign a unique global address to each local host.

The configuration of dynamic inside PAT is very similar to that of dynamic inside NAT. The only difference, in fact, is that when defining the global address pool, instead of using a range of addresses, you specify a single IP address (or the ASA interface).

To present a multi-interface translation scenario, the PAT configuration example will proceed as if there are no current translation rules present on the ASA. You will define the use of PAT for hosts on the inside interface when they initiate communication with hosts reachable through either the outside or DMZ interfaces of the ASA. Further, there will be occasions when hosts on the DMZ need to initiate connectivity to the outside world, so this example will configure PAT for those connections as well.

To begin the process, once again navigate to Configuration > Firewall > NAT Rules and click Add > Add Dynamic NAT Rule to create a new rule and to define an original interface and IP address range that will be subject to translation. In our example, this would be the inside interface and the 10.0.0.0/24 subnet. In the Add Dynamic NAT Rule dialog box, click Manage to open the Manage Global Pool dialog box, and then click Add to open the Add Global Address Pool dialog box, displayed in Figure 7-10. Here you will define a single global address to be used for PAT.

Figure 7-10 Configuring a PAT Global Address

image

In the Interface field, select the egress interface where the PAT address will be used. In Figure 7-10, the DMZ interface has been selected. Enter a valid NAT ID number in the NAT ID field. In the figure, the NAT ID has been set to 5 in this example. To configure the use of PAT, in the IP Addresses to Add area, click the Port Address Translation (PAT) radio button.

In the IP Address field, enter the global IP address that will be used for PAT. In Figure 7-10, the address that will be used is 172.16.0.254. Even though PAT implies the use of a single IP address, there is an optional Netmask field. This should always be set to 255.255.255.255 for PAT, as it is in Figure 7-10.

Click the Add button to move the address you defined to the Addresses Pool list. Then click OK to complete this PAT address creation and return to the Manage Global Pool dialog box.


Note

You can specify more than one PAT address with the same pool ID on the same interface. If port assignments are exhausted on the first address listed (which can occur in high-traffic environments where tens of thousands of concurrent sessions occur and use all ports in the 1024–65535 range), new port translations will occur using the second address in the list, and so on.


You have now configured the use of PAT when communicating with hosts reachable through the DMZ interface. To create another PAT rule, for use when communicating with hosts reachable through the outside interface, once again click Add to open the Add Global Address Pool dialog box, displayed in Figure 7-11. This time, you will configure the use of PAT by using the ASA interface address as the PAT address.

Figure 7-11 Configuring PAT Using the Interface Address

image

In Figure 7-11, the outside interface has been selected. Because the same local hosts will be using this translation rule, whether communicating through the DMZ or outside interface, the same NAT ID number must be used. Therefore, the figure shows this value once again being set to 5.

In the IP Addresses to Add area, click the Port Address Translation (PAT) Using IP Address of the Interface radio button instead of specifying a separate IP address.

Click OK in the Add Global Address Pool dialog box, and then click OK in the Manage Global Pool dialog box, to complete the definition of the new PAT addresses and return to the Add Dynamic NAT Rule dialog box.

Figure 7-12 shows the Add Dynamic NAT Rule dialog box, which now shows the two newly defined PAT addresses with the same NAT ID number listed in the Pool ID column.

Figure 7-12 Binding a PAT Address to a NAT Rule

image

To complete the definition of the new PAT translation rules for hosts on the inside subnet, select the newly configured PAT “pool” by clicking it, and then click the OK button.

The final portion of this configuration scenario is to configure PAT translation for hosts on the DMZ subnet, initiating communication to hosts on the outside. These hosts will use the same “pool” as the inside hosts—namely, the PAT rule using the outside interface IP address.

To associate a new set of original (local) host addresses with an existing pool, navigate once again to Configuration > Firewall > NAT Rules and then click Add > Add Dynamic NAT Rule to open the Add Dynamic NAT Rule dialog box. Figure 7-13 shows an example of defining a new source IP range to use an existing global pool.

Figure 7-13 Binding an Existing PAT Address to a NAT Rule

image

In the Original area of the Add Dynamic NAT Rule dialog box, from the Interface drop-down list, select the ingress interface for this NAT rule. In Figure 7-13, the DMZ interface is selected.

Next, in the Source field, enter the local IP address or address range that will be subject to this NAT rule. Optionally, you may click the ellipses (...) button to choose an IP address or range that has already been defined within Cisco ASDM. In Figure 7-13, the ellipses was clicked and the DMZ network was selected.

The last step is to select Pool ID 5 in the Translated area. Click OK to complete the binding and return to the NAT Rules window. Figure 7-14 shows the results in the NAT Rules window.

Figure 7-14 Completed NAT Rules Display

image

Note the number column (column header #). The numbers shown here are a strict sequence, starting at 1, and show how many NAT rules exist on the interface. It is not related to the NAT ID number configured in the NAT rules.

Finally, click Apply to send the configuration changes to your ASA.

The CLI commands generated by the changes made are as follows:

nat (DMZ) 5 172.16.0.0 255.255.255.0 tcp 0 0 udp 0
nat (inside) 5 10.0.0.0 255.255.255.0 tcp 0 0 udp 0
global (outside) 5 interface
global (DMZ) 5 172.16.0.254 netmask 255.255.255.255

If you are configuring the ASA from the CLI, you can enter these commands directly in global configuration mode. Do not worry for now about the tcp and udp parameters; they are covered elsewhere.


Note

Note the use of the keyword interface in the sample configuration. Not only is this convenient for situations where the ASA is dynamically addressed (as the PAT address will change when the interface address is changed), but is required, as attempting to enter the IP address of the ASA interface when entering this command would generate an error.


Configuring Dynamic Inside Policy NAT

In production networks, you might regularly encounter situations in which local hosts, communicating with different destinations through the same egress interface of the ASA, are required to have different translation rules for each set of destination addresses. In such situations, dynamic NAT or PAT as seen thus far is insufficient to handle the required translations. Examples of such situations include communication across a VPN tunnel to a network that is having addressing conflicts with the local network (possibly even overlapping IP address spaces), or connections to application vendors that require your entire network to appear to the application as a single, authorized IP address, and the PAT address normally used for these originating hosts cannot be used for some reason (perhaps because only a subset of local hosts using dynamic PAT are authorized to use the application).

Cisco ASAs support a feature known as policy NAT (or policy PAT), which allows you to specify which specific traffic flows (rather than only which source IP addresses) will be subject to a translation rule. You do this by defining a policy using an ACL, wherein flows defined with a permit entry become eligible for the policy NAT rule you create. ACL configuration is covered in detail in Chapter 8, “Controlling Access Through the ASA,” but this chapter presents some examples for the purpose of illustrating policy NAT rule creation. If you do not fully understand the examples because you do not understand the ACL used, feel free to return and read this section after you have read Chapter 8.

You can combine policy NAT with dynamic inside NAT and create dynamic inside policy NAT rules. In this case, you will translate the source IP addresses of your local hosts dynamically, depending on the specific definition of traffic flows in an ACL.

To demonstrate a case where dynamic inside policy NAT could be used, we will use the following configuration scenario: The original dynamic NAT configuration from earlier in the chapter is configured on the ASA. The PAT rules from the last section are not present. Several hosts in the 10.0.0.0/24 inside subnet are authorized to connect to a vendor application server on the Internet. This vendor requires all users coming from your organization to appear to their server as a single IP address. Because you are using one-to-one dynamic inside NAT, each internal host has a unique global address when translated.

Thus, you need to create a dynamic inside policy NAT rule to translate internal hosts to use a configured PAT address if they are communicating with the vendor application server, but still use the previously defined NAT rule (pool ID 1) when connecting elsewhere on the Internet.

The configuration scenario presented is based on the scenario in the preceding text. It assumes that all required routing is properly configured and that access rules allow all required communication between these hosts and the outside world.

To configure a dynamic inside policy NAT rule, navigate to Configuration > Firewall > NAT Rules and then click Add > Add Dynamic Policy NAT Rule to open the Add Dynamic Policy NAT Rule dialog box, shown in Figure 7-15. From this dialog box, you will define your policy for traffic flows subject to this new translation rule.

Figure 7-15 Configuring Dynamic Policy NAT Rule

image

In the Original area, from the Interface drop-down list, choose an interface that will be the ingress interface for hosts with local addresses to be translated. In Figure 7-15, the inside interface is selected.

In the Source field, enter local addresses, or use the ellipsis button to choose addresses already defined in Cisco ASDM. In the example, the inside-network object known to ASDM has been selected.

Next, in the Destination field, enter the destination address(es) to which these hosts will be connecting, to define specific traffic flows subject to translation. In Figure 7-15, the address 209.165.202.150 is entered (no mask is necessary because ASDM defaults to a /32 mask). This is the vendor application server address.

Optionally, you can further refine the definition of traffic flows subject to translation by selecting a service in the Service field, to specify the destination service (destination port) that the local hosts are connecting to when they become subject to this translation rule. In Figure 7-15, no service is selected, so all traffic destined to the vendor application server will be subject to this translation rule.

Now that you have defined a policy to select traffic flows subject to this translation rule, assign a PAT global address to this rule, using the same procedure covered in earlier examples. Click the Manage button on the right side of the Translated area to define the PAT address. This scenario assumes a NAT ID of 8 was used, with a PAT address of 209.165.200.134. Traffic flows subject to this translation policy will have the source IP address of the local host translated to this PAT address when completing the connection.


Note

This demonstrates an important concept in translation rules. It was stated earlier that any local host could match only one translation rule for any particular traffic flow. Policy NAT rules are evaluated before “regular” NAT rules, so even though this rule uses a pool ID of 8, it will be used, rather than pool ID 1, when packets match the defined policy. The pool IDs do not dictate the order of evaluation.


Select the newly created PAT pool. Click OK in the Add Dynamic Policy NAT Rule dialog box to complete the definition of the policy NAT rule. Finally, click Apply to send the changes to the ASA.

The CLI commands generated by the changes made are as follows:

access-list POLICY_NAT_ACL line 1 extended permit ip 10.0.0.0 255.255.255.0 host
  209.165.202.150
!
nat (inside) 8 access-list POLICY_NAT_ACL tcp 0 0 udp 0
global (outside) 8 209.165.200.134 netmask 255.255.255.255

The ACL name is changed from that assigned by ASDM for readability. If you are configuring the ASA from the CLI, you can enter these commands directly in global configuration mode.


Note

Deny access control entries (ACE) are not supported inside policy NAT ACLs. You should only define flows unidirectionally, using the local network as the source in the policy NAT ACL.


Verifying Dynamic Inside NAT and PAT

image

To examine existing translation table entries (translation slots), use the show xlate or show xlate details command.

Example 7-1 shows the use of the show xlate command based on the original configuration of dynamic inside NAT only. The output shows the number of translation slots currently in use, and the highest number of translation slots concurrently in use since the last reboot of the ASA. Finally, all active translation slots are displayed, with the keyword Global indicating the translated address and the keyword Local indicating the original address. Note that no interface information is contained in the output.

Example 7-1 show xlate Command Output (NAT)


FIREWALL# show xlate
1 in use, 3 most used
Global 209.165.200.254 Local 10.0.0.101


Example 7-2 shows the use of the show xlate command based on the PAT configuration created in the multi-interface scenario presented earlier in the chapter. For each translation slot entry, the keyword PAT appears before the Global keyword. Along with the global and local IP addresses, the number appearing in parentheses is the source port number in the packet, after translation (global) and prior to translation (local).

Example 7-2 show xlate Command Output (PAT)


FIREWALL# show xlate
3 in use, 10 most used
PAT Global 209.165.200.226(50595) Local 10.0.0.101(49298)
PAT Global 209.165.200.226(25788) Local 172.16.0.51(49297)
PAT Global 209.165.200.226(48335) Local 10.0.0.101(62474)


Example 7-3 shows the use of the show xlate detail command based on the configuration combining dynamic inside NAT with dynamic inside policy PAT. The show xlate detail command adds a table of Flag identifiers, for help in understanding the flags listed in the individual translation slot entries. Each translation slot entry also includes information on interfaces involved in the traffic flow. Each entry lists the ingress interface and original (local) address first, followed by the egress interface and translated (global) address. PAT entries indicate whether the protocol in use was TCP or UDP. Translations based on policies (ACLs) show the name of the ACL that defines the policy. Finally, entries contain flags denoting the type of NAT applied. Dynamic translations contain the i flag and PAT translations contain the r flag, for example.

Example 7-3 show xlate detail Command Output


FIREWALL# show xlate detail
2 in use, 8 most used
Flags: D - DNS, d - dump, I - identity, i - dynamic, n - no random,
       r - portmap, s - static
NAT from inside:10.0.0.101 to outside:209.165.200.240 flags i
TCP PAT from inside:10.0.0.101/49274 to
outside(POLICY_NAT_ACL):209.165.200.134/17637 flags ri


To manually clear the translation table and return all allocated slots to the pool for assignment, use the clear xlate command. This is highly recommended (Cisco even uses the word “required,” although this is not entirely accurate) whenever translation rules are changed. There are variations on this command (shown in the “Command Reference to Check Your Memory” section at the end of this chapter) that allow you to clear only certain translation slots, instead of the entire table. Because active connections that required translation will fail as soon as the underlying translation is cleared, it is important, in production environments, to clear only those translation slots necessary for your purpose.

Configuring Static Inside NAT

Static inside NAT creates permanent, fixed translations between a local address and a global address. Translation slots created using static translation rules are always present in the translation table, and are persistent across reboots. They have no idle timer leading to expiration. If you delete a static NAT rule from the ASA, the associated entries in the translation table are automatically removed.

image

Because translation slots based on static translation rules are always active, hosts from less secure networks can initiate communications to the statically translated local hosts, as long as the access list rules on the ASA permit such traffic. These factors make static inside NAT ideal for servers that need to be accessed from less secure interfaces, where the address configured on the server needs to be translated.

Figure 7-16 shows an example of this concept. There are two application servers, a web server and an FTP server, located on the DMZ network.

Figure 7-16 Static Inside NAT Example

image

The IP addresses configured on the hosts are private IP addresses—172.16.0.5 for the web server and 172.16.0.10 for the FTP server. These servers are regularly accessed by clients on the Internet at large. They must therefore have fixed IP addresses, which can be registered in DNS records that the Internet at large will use to find them. Because the private IP addresses configured on the servers cannot be registered in global DNS entries, these servers will use static inside NAT to provide fixed translations to global IP addresses.

Figure 7-16 shows an example where the web server’s local IP address of 172.16.0.5 will be translated to a global IP address of 209.165.200.228, and the FTP server’s local IP address of 172.16.0.10 will be translated to a global IP address of 209.165.200.229. When you create DNS records for these hosts, you will use those global addresses. When users on the Internet want to access these hosts, the packets they send will have one of those addresses as the destination IP address. The ASA will be responsible for translating that destination IP and forwarding the traffic to the correct server.

Note that static translations on a Cisco ASA are automatically bidirectional. In other words, unless you create translation rules that will supersede the static translations for these two hosts, if they were to initiate connectivity to hosts reachable through the outside interface of the ASA, their source IP address would be translated to the same global IP address at all times. For example, if the web server with local address 172.16.0.5 connected to an external host, perhaps to download updates for installed software packages, the source address in such packets would be translated to 209.165.200.228 before being forwarded by the ASA through the outside interface.

Recall the four pieces of information necessary for an ASA to perform NAT:

• Original source IP address (and port) in the packet

• Interface where the original packet enters the ASA (ingress interface)

• Interface where the packet will exit the ASA (egress interface)

• Translated address (and, optionally, port) to insert into the packet

When dynamic inside NAT was defined, the original IP address and interface were defined with the nat command, and the mapped (translated) IP address and interface were defined with the global command. These two commands were bound together by using the same NAT ID parameter in both.

Static inside NAT is different, in that all four required pieces of information are defined as a single command (and in a single ASDM window).

To begin the process, navigate to Configuration > Firewall > NAT Rules, and then click Add > Add Static NAT Rule to create a new rule. The Add Static NAT Rule dialog box will open, as shown in Figure 7-17, where you define a new static inside NAT rule.

Figure 7-17 Configuring a Static NAT Rule

image

In the Original area, you define the actual IP address of the host being translated (sometimes called real_ip in documentation) and the ingress interface for traffic arriving from that host (real_ifc). From the Interface drop-down list, select the ASA interface through which the host subject to translation is reached (where packets from said host will ingress to the ASA). In Figure 7-17, the DMZ interface is selected.

In the Source field, enter the local (real) IP address of the host that will be translated. In Figure 7-17, 172.16.0.5 is entered, defining the web server.

In the Translated area, you define the global address to which the host will be translated (called mapped_ip) when traffic from that host egresses the ASA on a selected interface (mapped_ifc). In this example, you are creating a mapping for the web server on the outside interface, so, in the figure, the outside interface is selected from the Interface drop-down list.

Click the Use IP Address radio button and enter the global (translated/mapped) IP address in the field. It is important that you not use a global IP address that is also defined as part of a global address pool on the same interface. In Figure 7-17, the global IP address of 209.165.200.228 is entered.

Click OK to accept the new static translation definition and close the Add Static NAT Rule dialog box. Using the same procedure, define the static translation for the FTP server, from real interface DMZ and address 172.16.0.10 to mapped interface outside and address 209.165.200.229, per the scenario information. Then click Apply to send the changes to the ASA.

The CLI commands generated by the changes made are as follows:

static (DMZ,outside) 209.165.200.228 172.16.0.5 netmask 255.255.255.255 tcp 0 0
  udp 0
static (DMZ,outside) 209.165.200.229 172.16.0.10 netmask 255.255.255.255 tcp 0 0
  udp 0

If you are configuring the ASA from the CLI, you can enter these commands directly in global configuration mode.


Note

If you are configuring static commands from the CLI, it is important to remember that the order of the interfaces is real and then mapped (or local and then global, if you prefer), but the order of IP addresses is mapped and then real (global and then local). Also, there is no space after the comma when specifying interface names. Inserting a space will generate a syntax error.



Note

When you are configuring static translations, static is the only command on the ASA where, in the absence of a configured network mask, a /32 netmask is assumed (the translation is for a single host). All other commands that have a netmask value as an available parameter default to a classful netmask if none is explicitly configured.


Configuring Network Static Inside NAT

Static inside NAT is not limited to defining host-specific translations. It is possible, with a single static translation, to statically translate an entire range of local addresses to a global address range of the same size.

Consider, for example, the network diagram shown in Figure 7-18. There are 32 servers located in the DMZ: 172.16.0.32–172.16.0.63. You have obtained from your ISP a global IP address block of 209.165.201.0/27, which is 32 addresses in size.

Figure 7-18 Network Static Inside NAT Scenario

image

Note that the ASA IP address of 209.165.200.226 is not part of the same network as the addresses assigned by your ISP. This is perfectly acceptable. By default, the ASA will act as a proxy ARP responder for any global addresses configured on its interfaces—it does not need to be attached to the network itself.


Note

When using address blocks for translation, as long as the ASA interface is not part of the defined network, it is not necessary to reserve out the addresses that would normally represent the network identifier (.0) and the directed broadcast address (.31). As long as the addresses are routed toward the firewall, all addresses in the block can be used for host translations.


So, you have 32 servers that will need static translations, and you have a block of 32 global addresses. If you were to use host-specific static translations, you would need to configure 32 of them. Is there a way to accomplish this with less configuration work? Yes! Network static translations (sometimes simply called “net statics”) are the answer to this need.

To begin the process, navigate to Configuration > Firewall > NAT Rules, and then click Add > Add Static NAT Rule to create a new rule. The Add Static NAT Rule dialog box opens, as shown in Figure 7-19.

Figure 7-19 Configuring a Network Static Inside NAT Rule

image

In the Original area, from the Interface drop-down list, select the ASA interface through which the host range subject to translation is reached (where packets from said host range will ingress to the ASA). In Figure 7-19, the DMZ interface is selected.

In the Source field, enter the local (real) IP address range of the hosts that will be translated, including a netmask value. In Figure 7-19, 172.16.0.32/27 is entered, defining the range of addresses from 172.16.0.32 through 172.16.0.63.

In the Translated area, you define the global address range and interface used for this translation. In Figure 7-19, the outside interface is selected from the Interface drop-down list.

Click the Use IP Address radio button and enter the global IP address range in the field, including a netmask value (the same as used to define the original address range). In Figure 7-19, the global IP address range of 209.165.201.0/27 is entered.


Note

The netmask value defines both the size of the block being translated and the specific bits being translated. In this example, the host portion of the original IP addresses is 32–63, but the global address range is 0–31. However, you are translating only the first 27 bits of the original address. So, for example, 172.16.0.39 (10101100.00010000.00000000.00100111) is translated to 209.165.201.7 (11010001. 10100101. 11001001.00000111). The first 27 bits are translated to equal the first 27 bits of the address in the Use IP Address field, and the last 5 bits are left unchanged.


Click OK to accept the new static translation definition and close the Add Static NAT Rule dialog box. Using the same procedure, define the static translation for the FTP server, from real interface DMZ and address 172.16.0.10 to mapped interface outside and address 209.165.200.229, per the scenario information. Then click Apply to send the changes to the ASA.

The CLI command generated by the changes made is as follows:

static (DMZ,outside) 209.165.201.0 172.16.0.32 netmask 255.255.255.224 tcp 0 0
  udp 0

If you are configuring the ASA from the CLI, you can enter this command directly in global configuration mode.

Configuring Static Inside PAT

Using static inside PAT, you can create a fixed translation from a local host IP address and local Layer 4 port (for TCP or UDP) to a global IP address and global Layer 4 port. Static inside PAT is useful when you want to allow inbound connectivity to a number of local servers, using a single global IP address. Remember, of course, that an interface access list on the ASA would still need to be configured to allow such connections (interface access lists are discussed in Chapter 8, “Controlling Access Through the ASA”). It also allows you to reuse a global IP address that is used for dynamic inside NAT/PAT (because outgoing sessions will use port numbers of 1024 and higher) to also support inbound connectivity to servers on specific global ports (which will generally be 1023 and below), forwarded to specific local hosts, on specific local ports.

Static inside PAT has the following characteristics:

• It supports only incoming sessions to the configured global address and port. If the local host also needs to initiate outgoing sessions, you should use either inside NAT or PAT rules to accomplish this.

image

• It supports the use of the ASA interface as the global address.

• It allows port redirection from a well-known global port to a custom local port, or vice versa. For example, a local web-based application server listens on the well-known TCP port 80. Incoming connections use a custom TCP port of 8080, and the static inside PAT rule redirects these to TCP port 80 when forwarding to the local server.

• It allows port redirection so that multiple local servers, using unique local ports, can share a single global IP address. For example, assume you have two local servers, a web-based application server listening for HTTPS on customized TCP port 8443, and a mail server listening for SMTP on TCP port 25. You have only one global IP address available. Incoming connections to the global IP address, on well-known TCP port 443, are forwarded to the web server on the custom port. Incoming connections to the same global IP address, on port 25, are forwarded to the mail server.

Figure 7-20 shows a network diagram based on the example just described. This will be the basis for the configuration scenario to demonstrate the use of static inside PAT.

Figure 7-20 Static Inside PAT Scenario

image

You have two servers located on the DMZ segment. The first, with a local IP address of 172.16.0.15, hosts a secure web-based application and listens for HTTPS connections on customized TCP port 8443. The second is a mail server, with a local IP address of 172.16.0.20, and listens for SMTP connections on TCP port 25. You have only one global IP address available for use, 209.165.200.230.

You will configure static inside PAT so that the two local servers, listening on unique local ports, can share the single available global IP address.

To begin the process, navigate to Configuration > Firewall > NAT Rules, and then click Add > Add Static NAT Rule to create a new rule. The Add Static NAT Rule dialog box will open, as shown in Figure 7-21.

Figure 7-21 Configuring a Static Inside PAT Rule

image

In the Original area, from the Interface drop-down list, select the ASA interface through which the hosts subject to translation are reached (where packets from said hosts will ingress to the ASA). In Figure 7-21, the DMZ interface is selected.

In the Source field, enter the local (real) IP address of the first server that will be translated. In Figure 7-21, 172.16.0.15 is entered, defining the secure web-based application server.

In the Translated area, select the interface where you will map the global IP address used in this translation. In Figure 7-21, the outside interface is selected from the Interface drop-down list.

Click the Use IP Address radio button and enter the global IP address in the field. In Figure 7-21, the global IP address of 209.165.200.230 is entered.


Note

Optionally, you could click the Use Interface IP Address radio button to use the IP address of the selected interface (outside in this example) as the global IP address used for this translation rule.


In the Port Address Translation (PAT) area, check the Enable Port Address Translation (PAT) check box. This will make the fields below this available for editing.

Next, select the radio button for the protocol for which you are translating ports: TCP or UDP. In Figure 7-21, the TCP radio button is selected.

In the Original Port field, enter the actual port on which the server is configured to listen. In Figure 7-21, port 8443 is configured.

In the Translated Port field, enter the port that will be specified as the destination port for inbound connections. This server requires port redirection, and port 443 is configured in this field.

Click OK to accept the new static translation definition and close the Add Static NAT Rule dialog box. Using the same procedure, define the static translation for the mail server, from real interface DMZ and address 172.16.0.20 to mapped interface outside and address 209.165.200.230, this time using TCP port 25 as both the original and translated port, because port redirection is not used for the mail server. Then click Apply to send the changes to the ASA.

The CLI commands generated by the changes made are as follows:

static (DMZ,outside) tcp 209.165.200.230 443 172.16.0.15 8443 netmask
  255.255.255.255 tcp 0 0 udp 0
static (DMZ,outside) tcp 209.165.200.230 25 172.16.0.20 25 netmask
  255.255.255.255 tcp 0 0 udp 0

If you are configuring the ASA from the CLI, you can enter these commands directly in global configuration mode.

These translations allow outside hosts to access either server in the DMZ by connecting to their global IP address and global port (assuming that access rules have been created to permit such connections). To access the secure web-based application server, outside hosts would connect to 209.165.200.230, TCP port 443. To access the mail server, outside hosts would connect to 209.165.200.230, TCP port 25.


Note

Static PAT allows you to use the same global IP address for many different static rules, provided the port is unique for each rule. You cannot use the same global IP address for multiple static NAT rules.


Configuring Static Inside Policy NAT

As previously mentioned, in production networks, local hosts communicating with different destinations through the same egress interface of the ASA regularly are required to have different translation rules for each set of destination addresses. Dynamic inside policy NAT allows you to provide different translation rules depending on the specific traffic flows involved. Static inside policy NAT does the same thing, while providing a fixed, rather than dynamic, address translation for the original local host.

The most common example where static inside policy NAT would be required is communication across a VPN tunnel to a network that is having addressing conflicts with the local network (possibly even overlapping IP address spaces).

As with dynamic policy NAT, this is done by defining a policy using an ACL, wherein flows defined with a permit entry become eligible for the static policy NAT rule you create. Permitted traffic flows will have their original source IP address statically translated to the global IP address provided in the static translation rule.

To demonstrate a case where static inside policy NAT could be used, consider the following configuration scenario: Your company, Company A, recently acquired another company, Company B, and you have established a VPN connection between the two sites. Users at Company B must be able to communicate with your mail server on the DMZ subnet (172.16.0.20:25), and your mail server must be able to communicate bidirectionally with the Company B mail server, which will eventually be phased out. However, Company B has a VPN with a vendor that also uses the 172.16.0.0/24 address space. Obviously, you cannot force the vendor to re-address its network.


Note

It is the fact that you need to allow bidirectional traffic initiation with the remote network that makes the use of static inside policy NAT necessary. The remote network must have a fixed IP address to which it connects in order to reach the local server, but the local server must also be able to initiate connectivity to the remote network. If only the remote network initiated connectivity, dynamic inside policy PAT could be used. If only the local host initiated connectivity, dynamic inside NAT might be able to be used.


Thus, you need to create a static inside policy NAT rule, which will allow these users to connect to your mail server using an address that will not conflict with their existing routing plan, while the server still uses the previously defined static PAT rule when connecting to the Internet.

Figure 7-22 presents a network diagram based on the scenario just described.

Figure 7-22 Static Inside Policy NAT Scenario

image

To begin the process, navigate to Configuration > Firewall > NAT Rules, and then click Add > Add Static Policy NAT Rule to create a new rule. The Add Static Policy NAT Rule dialog box will open, as shown in Figure 7-23.

Figure 7-23 Configuring a Static Inside Policy NAT Rule

image

In the Original area, from the Interface drop-down list, select the ASA interface through which the host subject to translation is reached. In Figure 7-23, the DMZ interface is selected.

In the Source field, enter the local IP address of the host that will be translated. In Figure 7-23, 172.16.0.20 is entered, defining the mail server.

Next, in the Destination field, enter the destination address(es) to which this host will be communicating, to define specific traffic flows subject to translation. In Figure 7-23, the address 10.10.10.0/24 is entered, specifying the internal network of Company B.

In the Translated area, select the interface where you will map the global IP address used in this translation. In Figure 7-23, the outside interface is selected from the Interface drop-down list.

Click the Use IP Address radio button and enter the global IP address in the field. In Figure 7-23, the global IP address of 172.18.0.20 is entered.

Click OK to accept the new static policy NAT definition and close the Add Static Policy NAT Rule dialog box. Then click Apply to send the changes to the ASA. Because the policy NAT rule just defined uses the same local address and same port pair as an existing static rule, Cisco ASDM will present you with a Warning message. Note that Warnings indicate an unusual condition that you should verify, whereas Errors indicate that the configuration is invalid.

The CLI commands generated by the changes made are as follows:

access-list POLICY_NAT_ACL2 line 1 extended permit ip host 172.16.0.20
  10.10.10.0 255.255.255.0
!
static (DMZ,outside) 172.18.0.20 access-list POLICY_NAT_ACL2 tcp 0 0 udp 0

The ACL name is changed from that assigned by ASDM for readability. If you are configuring the ASA from the CLI, you can enter these commands directly in global configuration mode.

Although the policy is configured for outgoing traffic, remember that the ASA will also apply the same condition to incoming traffic. That is, if mail server 172.16.0.20 is initiating connectivity to the 10.10.10.0/24 network, its source address will be translated to 172.18.0.20. Likewise, if hosts on the 10.10.10.0/24 network send traffic to 172.18.0.20, and this traffic is routed across the VPN to the ASA, after decryption, the destination address in the packets will be changed from 172.18.0.20 to 172.16.0.20, before being forwarded to the mail server on the DMZ.


Note

Static inside policy PAT can be defined in the same manner, by enabling PAT and specifying original and translated port numbers, after configuring the global IP address.


Verifying Static Inside NAT and PAT

As with dynamic inside NAT and PAT, static inside NAT and PAT can be verified using the show xlate or show xlate detail command.

The output of show xlate is the same regardless of whether translations are dynamic or static. There is nothing in the output that indicates a given xlate table entry is based on a static, rather than dynamic, translation rule.

Example 7-4, however, shows the use of the show xlate detail command. The show xlate details command adds a table of Flag identifiers, for help in understanding the flags listed in the individual translation slot entries. Each translation slot entry also includes information on interfaces involved in the traffic flow. Each entry lists the ingress interface and original (local) address first, followed by the egress interface and translated (global) address. PAT entries indicate whether the protocol in use was TCP or UDP. Translations based on policies (ACLs) show the name of the ACL that defines the policy. Finally, entries contain flags denoting the type of NAT applied. Static translations contain the s flag and PAT translations contain the r flag, for example.

Example 7-4 show xlate detail Command Output


FIREWALL# show xlate detail
6 in use, 6 most used
Flags: D - DNS, d - dump, I - identity, i - dynamic, n - no random,
       r - portmap, s - static
TCP PAT from DMZ:172.16.0.20/25 to outside:209.165.200.230/25 flags sr
TCP PAT from DMZ:172.16.0.15/8443 to outside:209.165.200.230/443 flags sr
NAT from DMZ:172.16.0.5 to outside:209.165.200.228 flags s
NAT from DMZ:172.16.0.10 to outside:209.165.200.229 flags s
NAT from DMZ:172.16.0.32 to outside:209.165.201.0 flags s
NAT from DMZ:172.16.0.20 to outside(POLICY_NAT_ACL2):172.18.0.20 flags s


To manually clear the translation table and return all allocated slots to the pool for assignment, use the clear xlate command. Because static translations are permanent, if you use the clear xlate command and then immediately use the show xlate command, all statically defined translation slots will appear in the xlate table.

Configuring No-Translation Rules

If you enable NAT control, you must configure translation rules for each host on a more secure interface that requires communication with hosts on less secure interfaces. There are many cases, however, where you will not require NAT for such communication.

For example, if a host on your inside network needs to communicate with a host on your DMZ network, there are no networks in the path that would consider either address nonroutable. As such, there is no reason why the original address of the host cannot remain as it is in the data packets. Other examples are when NAT will be performed by some other device in the data path of the traffic, so the ASA does not need to perform NAT.

Where NAT control is enabled but no translation is required or desired, you must configure no-translation rules to satisfy the requirement that you have addressed how NAT is to be handled for such communication—it is not to be performed.

image

The Cisco ASA provides three mechanisms that enable you to create translation rules that perform no actual translation:

• Dynamic identity NAT: Creates dynamic identity translation slots in the translation table (where local and global addresses are the same) when hosts on a more secure interface communicate with hosts on less secure interfaces

• Static identity NAT: Creates static identity translation slots in the translation table immediately as they are configured, which can support servers that do not require translation

• NAT bypass (exemption): Allows packets to completely bypass the ASA NAT engine, not creating translation slots at all

Configuring Dynamic Identity NAT

Dynamic identity NAT creates temporary translation slots in the translation table, which “translate” a local address on a specific interface to the same address on all lower-security interfaces. These slots are created by outbound packets from hosts configured for dynamic identity NAT arriving at the ASA. Because these slots come into existence only when outbound traffic occurs, this method is suitable to support only client systems, not servers.

When configuring dynamic identity NAT, you are not able to limit the nontranslation to specific global interfaces. For example, you cannot perform normal translation for hosts when they access the outside, while performing identity NAT when the same hosts access the DMZ.


Note

Remember that any given traffic flow can match only a single translation rule. Dynamic identity NAT has the same precedence as any other dynamic NAT rule (non-zero NAT ID pool number). Because the NAT ID number is selected from the nat command that most specifically matches the traffic being analyzed, it is important to ensure that you properly define the source address(es) subject to translation. For example, suppose a host of 10.0.0.75 is the source of packets and the ASA contains the following nat commands:

nat (inside) 0 10.0.0.0 255.255.255.0 tcp 0 0 udp 0
nat (inside) 5 10.0.0.64 255.255.255.192 tcp 0 0 udp 0

The command with NAT ID 5 is a more specific match, based on prefix length, than the identity NAT rule. As such, NAT would be performed, using global pool 5 on the egress interface. It is important to remember that the NAT ID number exists only to bind a nat command to a global pool—it does not imply ordinality (that is, lower numbers are not processed for a match prior to higher numbers). It is not the NAT ID number that determines which nat rule is applied to the traffic, but rather the prefix length to which the nat command address matches the source address in the packets.


Dynamic identity NAT is configured the exact same way as any other dynamic NAT rule, with one exception. To configure dynamic identity NAT, navigate to Configuration > Firewall > NAT Rules and click Add > Add Dynamic NAT Rule. The Add Dynamic NAT Rule dialog box opens, as shown in Figure 7-24. Note that this example assumes that previously defined NAT rules for hosts on the inside interface are no longer in place.

Figure 7-24 Configuring a Dynamic Identity NAT Rule

image

Define the original interface and IP address(es) subject to this NAT rule as you would for any dynamic inside NAT rule. In Figure 7-24, the inside network 10.0.0.0/24 is defined. Then, in the Translated area, select the predefined pool with NAT Pool ID 0. Because this example is for traffic from a higher-security interface (inside) to a lower-security interface (DMZ), choose the NAT 0 pool with (outbound) listed in the Interface column. The NAT Pool ID of 0 in an outbound direction has special significance to the ASA. It means that specified host addresses will not be translated to any lower-security interfaces, and that translation slots can be created only by outbound communication. Because source addresses on lower-security interfaces are not, by default, translated when traversing the ASA toward a higher-security interface (for example, Internet-sourced traffic trying to reach a web server in the DMZ), inbound identity NAT would be used only in the rare circumstances in which such translation was configured and you needed to override it.

Click OK in the Add Dynamic NAT Rule dialog box to complete the definition of the no-NAT rule. Finally, click Apply to send the changes to the ASA.

The CLI command generated by the changes made follows:

nat (inside) 0 10.0.0.0 255.255.255.0 0 0 tcp 0 0 udp 0

If you are configuring the ASA from the CLI, you can enter this command directly in global configuration mode.


Note

Because the ASA is not performing NAT for the inside network in this example, hosts on the inside network would not be able to communicate with any hosts outside the local network (on the Internet, for example) unless another device in the traffic path, such as an edge (sometimes called perimeter) router, performed NAT.


Configuring Static Identity NAT

Static identity NAT creates permanent translation slots in the translation table that “translate” a local address on a specific interface to the same address on a specific lower-security interface. These slots are created immediately upon configuration. Because these slots always exist, this method is suitable to support servers accepting inbound connections.

When configuring static identity NAT, you are able to limit the nontranslation to specific global interfaces. You can therefore perform normal translation for hosts when they access the outside, while performing identity NAT when the same hosts access the DMZ, for example.

The other significant difference with static (versus dynamic) identity NAT is that, access rules permitting, hosts on the less secure interface can access an identity-NAT “translated” server on the more secure interface, using its configured local IP address.

Consider the example shown in Figure 7-25. Your company has an SMTP gateway, 172.16.0.20, on the DMZ network. Mail must pass through this device when moving between the Internet and the internal network. When mail arrives from the Internet, it is passed through various security measures, such as filtering, virus checks, and so on, on the gateway device, and only then is forwarded to your company’s internal mail server, 10.0.0.20, on the inside network. Because both servers are part of the private-address space, no translation is necessary, but because either server may initiate communication, identity NAT must be performed statically, not dynamically.

Figure 7-25 Static Identity NAT Scenario

image

Static identity NAT is configured the exact same way as any other static NAT rules. To configure static identity NAT, navigate to Configuration > Firewall > NAT Rules and click Add > Add Static NAT Rule. The Add Static NAT Rule dialog box opens, as shown in Figure 7-26.

Figure 7-26 Configuring a Static Identity NAT Rule

image

The example that follows will configure the mail address scenario described in the preceding paragraphs.

Define the original interface and IP address(es) subject to this NAT rule as you would for any static NAT rule. In Figure 7-26, the inside interface is selected and the mail server address of 10.0.0.20 is specified.

In the Translated area, you define the interface where the global address to be configured will be used. In Figure 7-26, the DMZ interface is selected.

Click the Use IP Address radio button and enter the same IP address in this field as you did in the Source field. In Figure 7-26, the IP address 10.0.0.20 is entered in both fields.

Click OK to accept the new static translation definition and close the Add Static NAT Rule dialog box. Then click Apply to send the changes to the ASA.

The CLI command generated by the changes made follows:

static (inside,DMZ) 10.0.0.20 10.0.0.20 netmask 255.255.255.255 tcp 0 0 udp 0

If you are configuring the ASA from the CLI, you can enter this command directly in global configuration mode.

Configuring NAT Bypass (NAT Exemption)

image

The final, and most preferred, method to perform no translation in situations where NAT control is enabled is NAT bypass (commonly referred to as “NAT 0 with an ACL” or “policy identity NAT”).

NAT bypass allows configured traffic flows to completely bypass the ASA’s NAT engine. Clients and/or servers not requiring translation are thus allowed to communicate without the creation of any translation slots in the translation table (which reduces device processing overhead).

The most common use of NAT bypass is for traffic that will cross the Internet inside a VPN tunnel. Because the original source address is not visible to the Internet, where it would be considered nonroutable, it is generally preferred not to translate this traffic. The other time NAT bypass can be used is when hosts on a more secure interface need to communicate with hosts on a less secure interface, but do not need to accept inbound connections (where the use of static identity NAT is appropriate).

The configuration scenario will be to set up NAT bypass for traffic originating on the inside network and destined for the DMZ network. Because this traffic is contained inside the internal network space, no translation is necessary. Also, in this scenario, hosts on the DMZ never initiate connections to the inside—they are always the server part of the client/server pair.

To configure NAT bypass, navigate to Configuration > Firewall > NAT Rules and click Add > Add NAT Exempt Rule. The Add NAT Exempt Rule dialog box opens, as shown in Figure 7-27. In this dialog box, you will define a full traffic flow policy (which becomes an ACL, hence the common name “NAT 0 with an ACL”) and enable the defined flow to bypass the NAT engine.

Figure 7-27 Configuring a NAT Bypass Rule

image

In the Original area, from the Interface drop-down list, select the ASA interface through which the host(s) subject to translation exemption can be reached. In Figure 7-27, the inside interface is selected.

In the Source field, enter the local IP address of the host(s) that will bypass NAT. In Figure 7-27, 10.0.0.0/24 is entered, defining the inside network.

Next, in the Destination field, enter the destination address(es) to which traffic that will bypass NAT will be destined, to define specific traffic flows subject to translation exemption. In Figure 7-27, the address 172.16.0.0/24 is entered, specifying the DMZ network.

Click the NAT Exempt Outbound Traffic from Interface ‘inside’ to Lower Security Interfaces (Default) radio button to enable NAT bypass.

Click OK to accept the new NAT bypass rule definition and close the Add NAT Exempt Rule dialog box. Then click Apply to send the changes to the ASA.

The CLI commands generated by the changes made are as follows:

access-list NO_NAT line 1 extended permit ip host 10.0.0.0 255.255.255.0
  172.16.0.0 255.255.255.0
!
nat (inside) 0 access-list NO_NAT tcp 0 0 udp 0

The ACL name is changed from that assigned by ASDM for readability. If you are configuring the ASA from the CLI, you can enter these commands directly in global configuration mode.


Note

You can apply only a single NAT bypass rule to any one interface. As such, all traffic to be exempted from NAT, when ingressing through a given interface, must be defined as part of the same ACL.


NAT Rule Priority with NAT Control Enabled

It has been mentioned more than once in this chapter that any specific traffic flow can match only one NAT rule. This is not to say that conflicting NAT rules cannot be configured, but rather that only one NAT rule can be applied to a packet as it ingresses the ASA through an interface where a NAT rule exists.

It is therefore important to know how, in the presence of conflicting rules, an ASA prioritizes the rules. The ASA will apply the NAT rule with the highest precedence that matches the packets being subjected to NAT control.

The order in which rules appear in the ASA configuration matters, as most NAT is applied to the first rule encountered that matches the packets being checked. The one exception is dynamic NAT, which, as has already been mentioned, will apply the rule with the best (longest bit pattern) match to the source address in the packets being checked.

The precedence of NAT rules, with NAT control enabled, is as follows:

1. NAT bypass (exemption) (nat 0 access-list): Supersedes all other translation rules, and searched in the order in which the rules appear in the configuration, with the first matching rule applied.

image

2. Static NAT and static PAT (policy and regular): Searched in the order in which the rules appear in the configuration, with the first matching rule applied.

3. Policy dynamic NAT (nat nat_id access-list): Searched in the order in which the rules appear in the configuration, with the first matching rule applied.

4. Regular dynamic NAT (including dynamic identity NAT - NAT 0 without ACL): Searches all dynamic NAT rules applied to the ingress interface, and applies the rule with the best (longest bit pattern) match to the local address.

If NAT control is enabled, and a packet does not match any of the rules listed, the packet is dropped. If NAT control is disabled (the default), packets not matching a translation rule are forwarded without translation, if permitted by security policy.

Configuring Outside NAT

All the NAT examples presented thus far have been inside NAT, which is applied to packets that ingress an interface that has a higher security level than the interface they egress. Outside NAT is exactly the opposite—it is applied to packets that ingress a lower security interface than they egress (inbound traffic).

Outside NAT is always optional (and actually fairly rare), even if NAT control is enabled. Consider the very common example of traffic entering an ASA from the Internet (presumably, through the outside interface). There is rarely a reason why the source address of such traffic would need to be altered.

Situations that would require outside NAT are generally due either to overlapping IP address spaces needing to communicate with each other (likely through a VPN) or to external hosts connecting to applications that are configured to service only specific client addresses (and the source address of the external host must therefore be translated to an authorized source address).

Occasionally, you will need to apply both inside NAT and outside NAT to the same traffic flow (almost always due to overlapping IP addresses on the network requiring communication). This is known as bidirectional NAT, sometimes also called dual NAT.

Configuration of outside NAT is exactly the same as configuration of inside NAT, with the exception that the Original or Source (policy NAT/PAT rules only) fields will refer to a lower-security interface, and the Translated or Destination (policy NAT/PAT rules only) fields will refer to a higher-security interface.


Note

Although it is possible to configure dynamic outside NAT, there are caveats to its use, and it is generally not recommended. You should, instead, use static outside NAT when outside NAT is necessary.


The configuration scenario has a server on the inside network that is configured to accept connection requests only from IP addresses on the 10.0.0.0/20 network. However, you have customers who will regularly access this server to obtain customized reports. These reports are based on information in the public domain, so they do not require encryption. One such customer is using PAT on their edge device, so all their users, when their traffic arrives at the ASA outside interface, appear to be coming from IP address 209.165.202.135. Figure 7-28 illustrates the network topology for this scenario.

Figure 7-28 Outside NAT Scenario

image

Because the traffic arrives at the ASA with a public source IP address, but the application server will only accept connections from IP addresses in the 10.0.0.0/20 address space, you will need to perform static outside NAT on the incoming requests, before forwarding them to the application server.

To configure static outside NAT, navigate to Configuration > Firewall > NAT Rules and then click Add > Add Static NAT Rule. The Add Static NAT Rule dialog box will open, as shown in Figure 7-29, where you define a new static outside NAT rule.

In the Original area, you define the actual IP address(es) being translated, and the ingress interface for traffic arriving from such address(es). From the Interface drop-down list, select the ASA interface through which the host subject to translation is reached (where packets from said host will ingress the ASA). Because this is outside NAT, the original interface will be the less secure interface in the traffic path. In Figure 7-29, the outside interface is selected.

Figure 7-29 Configuring a Static Outside NAT Rule

image

In the Source field, enter the real IP address of the host(s) that will be translated. In Figure 7-29, the customer PAT address of 209.165.202.135 is entered.

In the Translated area, you define the address to which the host(s) will be translated when traffic from such host(s) egresses the ASA on a selected interface. In our example, we are creating a mapping for the customer traffic on the inside interface, so, in Figure 7-29, the inside interface is selected.

Click the Use IP Address radio button and enter the translated (mapped) IP address in the field. In Figure 7-29, the IP address of 10.0.8.135 is entered, which is an address we have allocated for use by this customer.


Note

Although not used in this example, it is perfectly permissible to use an IP address that overlaps the internal 10.0.0.0/24 network, such as 10.0.0.135, so long as you have ensured that address will never be allocated to an actual internal host. For instance, you might exclude a range of IP addresses from assignment by local DCHP, and use such a range for outside NAT assignments.


Click OK to accept the new static translation definition and close the Add Static NAT Rule dialog box. Then click Apply to send the changes to the ASA.

The CLI command generated by the changes made follows:

static (outside,inside) 10.0.8.135 209.165.202.135 netmask 255.255.255.255 tcp 0
  0 udp 0

If you are configuring the ASA from the CLI, you can enter this command directly in global configuration mode.


Note

The order in which interfaces and IP addresses are specified when using outside NAT is still real, mapped, mapped, real, just as in any other static command. Similarly, if you are using dynamic outside NAT (which is not recommended), the nat command would be bound to the less secure interface (outside in our example) and the global pool would exist on the more secure interface (inside in our example).


Other NAT Considerations

The performance of NAT was one of the principle functions of ASAs in most production networks. It is important to consider the ramifications that the changing of addresses has on other items in the ASA configuration. Several such items are discussed in this section.

DNS Rewrite (Also Known as DNS Doctoring)

Static inside NAT is normally performed for servers, so that external hosts, upon receiving the IP address of the server from an Internet-based DNS server, can route traffic to the server’s global IP address. Such traffic will arrive at the ASA and then be redirected to the internal server based on the interface and IP address in the static command.

image

However, what if the client is on the internal network? If you are using an internal DNS server, this presents no problems, as the local IP address of the server would be returned to the client performing a DNS query.

Figure 7-30 illustrates a network where internal clients make DNS queries to an external DNS server when looking for an internal server. This would present a problem, which the DNS Rewrite feature is designed to solve.

Figure 7-30 DNS Rewrite Scenario

image

The problem arises from the fact that the Internet-based DNS server does not know the private IP address of the server, or which DNS queries come from the same internal network as where the server is located. So, if client 10.0.0.103 were to send to the DNS server a DNS query looking for the server www.ciscopress.ccnp, the only address the server would know to respond with would be 209.165.200.228, the global IP address of the web server, as configured earlier. If the client were to attempt a connection to this address, it would be unsuccessful, as the server is actually located in the DMZ, but the global IP address would route through the outside interface.


Note

DNS Rewrite is supported for both static and dynamic NAT rules.


With DNS Rewrite enabled, the ASA inspects inbound DNS replies and, if the IP address being returned is a global IP address configured with a static inside NAT rule, translates the address inside the DNS reply to be the local IP address of the server. So, the 209.165.200.228 address embedded in the DNS reply would match the static inside NAT rule for the web server, and the ASA would translate this to the local IP address 172.16.0.5 before forwarding the reply to the requesting client. Client 10.0.0.103 would now attempt its connection to 172.16.0.5, which would be successful.


Note

DNS inspection must be enabled for DNS Rewrite to function.


To configure DNS Rewrite for hosts using static inside NAT translation, navigate to Configure > Firewall > NAT Rules. Click Add > Add Static NAT Rule if you are creating a new rule, or Edit > Edit Static NAT Rule if you are adding DNS Rewrite to an existing static translation rule. Click the expand symbol to the right of the words Connection Settings to make the DNS Rewrite option visible (it is hidden by default). Figure 7-31 shows an example of editing the static inside NAT rule previously configured for the web server. The Connection Settings area has already been expanded.

Figure 7-31 Configuring DNS Rewrite

image

Check the Translate the DNS Replies That Match the Translate Rule check box to enable DNS Rewrite for this static translation rule.

Click OK to accept the change and close the Add/Edit Static NAT Rule dialog box. Then click Apply to send the changes to the ASA.

The CLI commands generated by the changes made are as follows:

no static (DMZ,outside) 209.165.200.228 172.16.0.5 netmask 255.255.255.255
static (DMZ,outside) 209.165.200.228 172.16.0.5 netmask 255.255.255.255 dns tcp
  0 0 udp 0

If you are configuring the ASA from the CLI, you can enter these commands directly in global configuration mode. The no command is generated because you are editing an existing rule.

Integrating NAT with ASA Access Control

Configuring NAT rules on an ASA impacts the configuration of access control rules, including interface access rules (interface ACLs), which filter traffic, user AAA rules (for Cut-through Proxy services), and Modular Policy Framework service policies (which can affect traffic handling in a number of ways), as they all typically refer to IP addresses that may be subject to translation.

In the case of interface ACLs, you must keep the following in mind:

• For inbound ACLs (applied to traffic as it ingresses the ASA through the interface), access rules are applied before NAT takes place. Therefore, an access control entry (ACE, a single line of an ACL) that filters source addresses must refer to the untranslated (original) address(es) of the source host(s). An access list that filters based on destination addresses must refer to the translated (mapped) address(es) of the destination host(s). This is true whether the traffic is moving from a higher-security interface to a lower-security interface (outbound flow) or vice versa (inbound flow).

image

Example 1: An ACL is applied inbound to the inside interface (more secure to less secure, or outbound connections). The source addresses referenced should be the local (untranslated) addresses. In our sample network, for example, you would permit or deny access from addresses in the 10.0.0.0/24 network.

Example 2: An ACL is applied inbound to the outside interface (less secure to more secure, or inbound connections). The destination addresses referenced should be the global (translated) addresses. In our sample network, for example, you would permit or deny access to the 209.165.200.228 address of the web server.

• For outbound ACLs (applied to traffic as it egresses the ASA through the interface), access rules are applied after NAT has taken place. Therefore, an ACE that filters source addresses must refer to the translated (global) address(es) of the source host(s). An access list that filters based on destination addresses must refer to the untranslated (original) address(es) of the destination host(s). This is true whether the traffic is moving from a higher-security interface to a lower-security interface (outbound flow) or vice versa (inbound flow).

Example 1: An ACL is applied outbound to the outside interface (outbound connections). The source addresses referenced should be the global (translated) addresses. In our sample network, for example, such a rule would apply whether traffic originated on the inside or the DMZ networks, as both would egress through the outside interface to reach the Internet. You would permit or deny access from addresses in the 209.165.200.224/27 address range, which was used for our translation examples.

Example 2: An ACL is applied outbound to the DMZ interface (which would be an inbound connection if originating on the outside interface, or an outbound connection if originating on the inside interface). The destination addresses referenced should be the local (untranslated) addresses of hosts on the DMZ. In our sample network, for example, you would permit or deny access to addresses in the 172.16.0.0/24 network.

Integrating NAT with MPF

If you apply Modular Policy Framework rules (discussed in Chapter 9, “Inspecting Traffic”) to traffic flows subject to NAT, similar rules apply. MPF rules, like access lists, can apply to traffic either as it ingresses the ASA through an interface or as it egresses the ASA through an interface.

In the case of MPF rules, the same rules apply as for interface ACLs:

• For rules applied to traffic as it ingresses an interface:

• The class flow specification must reference the untranslated IP address as the source IP address.

• The class flow specification must reference the translated IP address as the destination IP address.

• For rules applied to traffic as it egresses an interface:

• The class flow specification must reference the translated IP address as the source IP address.

• The class flow specification must reference the untranslated IP address as the destination IP address.

Integrating NAT with AAA (Cut-Through Proxy)

AAA (Cut-through Proxy) rules applied to an interface only affect traffic ingressing the ASA through that interface. The same rules for ingress traffic apply as those listed for MPF rules:

• The AAA rule must reference the untranslated IP address as the source IP address.

• The AAA rule must reference the translated IP address as the destination IP address.

Troubleshooting Address Translation

Troubleshooting NAT requires that you observe activity on the ASA itself while generating traffic to or from a host subject to translation rules. The most common commands used for this purpose are show xlate, show xlate detail, and clear xlate, which have all been examined already in this chapter. It also requires reviewing log messages generated by the address translation process (or access rules).

Improper Translation

If traffic does not appear to be translated according to a configured NAT rule you are expecting to perform the translation, you should consider performing the following steps in troubleshooting:

Step 1. Verify whether the traffic is being translated at all. Remember that if NAT control is enabled, and no translation rules are configured for a traffic flow, the traffic will be dropped. Use the show xlate or show xlate detail command to look for translations. Clear the translation table with clear xlate if recent changes have been made to translation rules.

Step 2. If traffic is not being translated, look for missing nat, global, or static commands, nat and global commands that do not have the same NAT ID number, or incorrect interface pairs configured within a static command.

Step 3. If traffic is being translated, but not by the correct NAT rule, check for overlapping translation rules. Keep in mind the order of precedence for NAT rules, from NAT bypass at the top to dynamic NAT at the bottom.

Protocols Incompatible with NAT or PAT

Some protocols encounter problems when running over NAT (and especially PAT). Ensure that any application traffic subject to translation rules on the ASA do not have the following features:

• Protocols that embed IP addresses at the application layer (within the data portion of packets, rather than the headers), unless the protocol is specifically supported by ASA packet inspection rules.

• Protocols that embed IP addresses at the application layer and use end-to-end encryption. If the payload of packets is encrypted when crossing through the ASA, even protocols supported by ASA packet inspection rules will not be properly translated.

• Protocols that include the IP or TCP/UDP headers as input to authentication hashing algorithms. These will not work with NAT or PAT, respectively, because NAT or PAT would be altering the headers subject to the integrity check (the AH protocol used within IPsec, and authenticated BGP routing updates are examples of this).

In such cases, exempt application traffic using such protocols from NAT by using NAT bypass (preferred) or static identity NAT.

Proxy ARP

When address translation is configured on a Cisco ASA, the ASA performs proxy ARP for all global addresses in its translation table by default (note that this is for addresses in the translation table, not for addresses merely configured for NAT). In some cases, this is not desired because it might interfere with the proper operation of adjacent hosts.

You can disable proxy ARP behavior of the ASA on an interface by using the sysopt noproxyarp interface_name command in global configuration mode.


Caution

Extreme care should be taken before disabling proxy ARP on an ASA interface when NAT control is enabled. For example, if it were disabled on the outside interface, the ASA would not reply to ARP requests for any of the global IP addresses of internal servers subject to static inside NAT, and no hosts from the Internet would be able to initiate connections to any such servers.


NAT-Related Syslog Messages

Problems performing address translation will be logged by the ASA. These messages can assist you in narrowing your troubleshooting focus. One of the most common NAT-related syslog messages occurs when the ASA cannot create a translation slot because it was either unable to find a matching global pool (on the correct interface, with the correct pool number) or the pool addresses are exhausted.

The following syntax shows the system message 305005. This message is generated when a packet does not match any of the configured translation rules, while NAT control is enabled. The same message is used whether the session should have matched dynamic or static translation rules:

%PIX|ASA-3-305005: No translation group found for protocol src
interface_name:source_address/source_port dst
  interface_name:dest_address/dest_port

The following syntax shows the system message 305006. There are several variations to this message, depending on which type of NAT rule and which protocol are involved. For instance, a static mapping “fails” if the ASA attempts to perform translation to an address that is a network identifier or broadcast address. A portmap failure indicates a problem applying PAT.

%PIX|ASA-3-305006: {outbound static|identity|portmap|regular)
translation creation failed for protocol src
  interface_name:source_address/source_port
dst interface_name:dest_address/dest_port

Exam Preparation Tasks

As mentioned in the section “How to Use This Book” in the Introduction, you have a couple of choices for exam preparation: the exercises here, Chapter 16, “Final Preparation,” and the exam simulation questions on the CD-ROM.

Review All Key Topics

Review the most important topics in this chapter, noted with the Key Topics icon in the outer margin of the page. Table 7-4 lists a reference of these key topics and the page numbers on which each is found.

Table 7-4 Key Topics for Chapter 7

image

image

Define Key Terms

Define the following key terms from this chapter and check your answers in the glossary:

ingress interface,

egress interface,

NAT,

PAT,

xlate table,

static NAT,

dynamic NAT,

inside NAT,

outside NAT,

dynamic inside NAT,

static inside NAT,

dynamic outside NAT,

static outside NAT,

NAT exemption,

NAT control,

bidirectional NAT,

DNS Rewrite,

proxy ARP

Command Reference to Check Your Memory

This section includes the most important configuration and EXEC commands covered in this chapter. It might not be necessary to memorize the complete syntax of every command, but you should be able to remember the basic keywords that are needed.

To test your memory of the commands, cover the right side of Table 7-5 with a piece of paper, read the description on the left side, and then see how much of the command you can remember.

Table 7-5 Commands Related to ASA Translation

image

image

The FIREWALL exam focuses on practical, hands-on skills that are used by a networking professional. Therefore, you should be able to identify the commands needed to configure and test an ASA feature.