Guest

Cisco PIX 500 Series Security Appliances

Using NAT and PAT Statements on the Cisco Secure PIX Firewall

Cisco - Using NAT and PAT Statements on the Cisco Secure PIX Firewall

Document ID: 15243

Updated: Oct 24, 2008

   Print

Introduction

This document provides examples of basic Network Address Translation (NAT) and Port Address Translation (PAT) configurations on the Cisco Secure PIX Firewall. This document also provides simplified network diagrams. Consult the PIX documentation for your PIX software version for detailed information.

Interactive: This document offers customized analysis of your Cisco device.

Refer to PIX/ASA 7.x NAT and PAT Statements in order to learn more about the basic NAT and PAT configurations on the Cisco PIX 500 Series Security Appliances.

Refer to Using nat, global, static, conduit, and access-list Commands and Port Redirection(Forwarding) on PIX in order to learn more about the nat, global, static, conduit, and access-list Commands and Port Redirection(Forwarding) on PIX 5.x and later.

Prerequisites

Requirements

Cisco recommends that you have knowledge of the Cisco Secure PIX Firewall.

Components Used

The information in this document is based on these software and hardware versions:

  • Cisco Secure PIX Firewall Software version 5.3.1 and later.

Note: Policy NAT was introduced from 6.2.

The information in this document was created from the devices in a specific lab environment. All of the devices used in this document started with a cleared (default) configuration. If your network is live, make sure that you understand the potential impact of any command.

Conventions

Refer to the Cisco Technical Tips Conventions for more information on document conventions.

Multiple NAT Statements with NAT 0

Network Diagram

19-01.gif

In this example, the ISP provides the network manager with an IP address block 209.165.201.0/27 that ranges from 209.165.201.1 to 209.165.201.30. The network manager decides to assign 209.165.201.1 to the inside interface on the Internet router, and 209.165.201.2 to the outside interface of the PIX.

The network administrator already has a Class C address assigned to the network, 192.168.10.0/24, and has some workstations that use these addresses in order to access the Internet. These workstations do not require any address translation as they already have valid addresses. However, new workstations are assigned addresses in the 10.0.0.0/8 network and they need to be translated (because 10.x.x.x is one of the unroutable address spaces per RFC 1918 leavingcisco.com.

In order to accommodate this network design, the network administrator must use two NAT statements and one global pool in the PIX configuration:

global (outside) 1 209.165.201.3-209.165.201.30 netmask 255.255.255.224
nat (inside) 0 192.168.10.0 255.255.255.0 0 0
nat (inside) 1 10.0.0.0 255.0.0.0 0 0 

This configuration does not translate the source address of any outbound traffic from the 192.168.10.0/24 network. It translates a source address in the 10.0.0.0/8 network into an address from the range 209.165.201.3 through 209.165.201.30.

Note: When you have an interface with a NAT policy and if there is no global pool to another interface, you need to use nat 0 in order to set up NAT exception.

Multiple Global Pools

Network Diagram

19-02.gif

In this example, the network manager has two ranges of IP addresses that are registered on the Internet. The network manager must convert all of the internal addresses, which are in the 10.0.0.0/8 range, into registered addresses. The ranges of IP addresses that the network manager must use are 209.165.201.1 through 209.165.201.30 and 209.165.200.225 through 209.165.200.254 . The network manager can do this with:

global (outside) 1 209.165.201.3-209.165.201.30 netmask 255.255.255.224
global (outside) 1 209.165.200.225-209.165.200.254 netmask 255.255.255.224
nat (inside) 1 0.0.0.0 0.0.0.0 0 0

Note that a wildcard addressing scheme is used in the NAT statement. This statement tells the PIX to translate any internal source address when it goes out to the Internet. The address in this command can be more specific if desired.

Mix NAT and PAT Global Statements

Network Diagram

19-03.gif

In this example, the ISP provides the network manager with a range of addresses from 209.165.201.1 to 209.165.201.30 for the company to use. The network manager has decided to use 209.165.201.1 for the inside interface on the Internet router and 209.165.201.2 for the outside interface on the PIX. You are then left with 209.165.201.3 through 209.165.201.30 to use for the NAT pool. However, the network manager knows that, at any one time, there can be more than 28 people that try to go out of the PIX. The network manager has decided to take 209.165.201.30 and make it a PAT address so that multiple users can share one address at the same time.

global (outside) 1 209.165.201.3-209.165.201.29 netmask 255.255.255.224
global (outside) 1 209.165.201.30 netmask 255.255.255.224
nat (inside) 1 0.0.0.0 0.0.0.0 0 0

These commands instruct the PIX to translate the source address to 209.165.201.3 through 209.165.201.29 for the first 27 internal users to pass across the PIX. After these addresses are exhausted, the PIX then translates all subsequent source addresses to 209.165.201.30 until one of the addresses in the NAT pool becomes free.

Note: A wildcard addressing scheme is used in the NAT statement. This statement tells the PIX to translate any internal source address when it goes out to the Internet. The address in this command can be more specific if desired.

Multiple NAT Statements with NAT 0 Access-List

Network Diagram

19-04.gif

In this example, the ISP again provides the network manager with a range of addresses from 209.165.201.1 to 209.165.201.30 . The network manager decides to assign 209.165.201.1 to the inside interface on the Internet router and 209.165.201.2 to the outside interface of the PIX.

However, in this scenario, another private LAN segment is placed off of the Internet router. The network manager prefers not to waste addresses from the global pool when hosts in these two networks talk to each other. The network manager still needs to translate the source address for all of the internal users (10.0.0.0/8) when it goes out to the Internet.

access-list 101 permit ip 10.0.0.0 255.0.0.0 192.168.1.0 255.255.255.0
global (outside) 1 209.165.201.3-209.165.201.30 netmask 255.255.255.224
nat (inside) 0 access-list 101
nat (inside) 1 10.0.0.0 255.0.0.0 0 0

This configuration does not translate those addresses with a source address of 10.0.0.0/8 and a destination address of 192.168.1.0/24. It translates the source address from any traffic initiated from within the 10.0.0.0/8 network and destined for anywhere other than 192.168.1.0/24 into an address from the range 209.165.201.3 through 209.165.201.30 .

If you have the output of a write terminal command from your Cisco device, you can use the Output Interpreter Tool (registered customers only) .

Use Policy NAT

Network Diagram

19-05.gif

When you use an access list with the nat command for any NAT ID other than 0, you enable policy NAT.

Policy NAT allows you to identify local traffic for address translation by the specification of the source and destination addresses (or ports) in an access list. Regular NAT uses source addresses/ports only. Policy NAT uses both source and destination addresses/ports.

Note: All types of NAT support policy NAT except for NAT exemption (nat 0 access-list). NAT exemption uses an access control list in order to identify the local addresses, but differs from policy NAT in that the ports are not considered.

With policy NAT, you can create multiple NAT or static statements that identify the same local address as long as the source/port and destination/port combination is unique for each statement. You can then match different global addresses to each source/port and destination/port pair.

In this example, the network manager has to provide access for destination IP address 172.30.1.11 for port 80 (web) and port 23 (Telnet), but must use two different IP addresses as a source address. 209.165.201.3 is used as a source address for web and 209.165.201.4 is used for Telnet, and must convert all of the internal addresses, which are in the 10.0.0.0/8 range. The network manager can do this with:

access-list WEB permit tcp 10.0.0.0 255.0.0.0 
172.30.1.11  255.255.255.255 eq 80
access-list TELNET permit tcp 10.0.0.0 255.0.0.0 172.30.1.11  
255.255.255.255 eq 23 

nat (inside) 1 access-list WEB
nat (inside) 2 access-list TELNET
global (outside) 1 209.165.201.3  255.255.255.224
global (outside) 2 209.165.201.4  255.255.255.224

You can use Output Interpreter Tool (registered customers only) in order to display potential issues and fixes.

Related Information

Updated: Oct 24, 2008
Document ID: 15243