Configuring Network Address Translation on a Cisco router
Configuring Network Address Translation on a Cisco router

Use this as a template when configuring NAT on a Cisco router
(This assumes IP and routing have already been configured)


This example assumes that a Cisco 1601 router is used, with one Ethernet port and one Serial port. A modem is connected to the Serial port, and is used to dial into an ISP. The router is issued a static PPP address at each dial-in, and a range of 5 IP addresses has been assigned to this customer, but from the same address range as the address assigned to the dialer port.

This is common way for customers to try and pinch pennies, since an ISP often charges less to assign static IP addresses from one address-range used for PPP connections, than they charge to assign a customer their own subnet.

In this example, these 5 addresses are used to provide Internet-routable addresses to 5 hosts on the LAN segment, which are using private, non-Internet routable RFC 1918 addresses, 10.0.0.0 /24.

These translations are, in this example, assigned statically: each host on the LAN is always assigned the same external address when translated. This could alternately be configured as a pool, where the router chooses an address to translate randomly. Static translation is preferable when this is used as a remote-office solution, where this LAN might be a remote office connecting through their Local ISP to their main office across the Internet, but through a firewall at the remote end. Using static addresses allows the firewall to build rules against specific addresses on the remote office LAN.

Cisco IOS Config

username billGates password Linux

chat-script dialnum ABORT ERROR ABORT BUSY "" "ATDT\T" TIMEOUT 60 CONNECT

ip nat inside source static 10.10.10.6 212.32.8.98
ip nat inside source static 10.10.10.7 212.32.8.99
ip nat inside source static 10.10.10.8 212.32.8.100
ip nat inside source static 10.10.10.9 212.32.8.101
ip nat inside source static 10.10.10.10 212.32.8.102

interface Ethernet0
description Connects to my local LAN
ip address 10.10.10.1 255.255.255.0
ip nat inside

interface Serial0
description This is the port I plug my modem into.
physical-layer async
no ip address
ip nat outside
encapsulation ppp
dialer in-band
dialer rotary-group 0
async default routing
async mode dedicated

interface Dialer0
description This logical interface dials into my favorite ISP
ip address 212.32.8.97 255.255.255.224
ip nat outside
encapsulation ppp
dialer in-band
dialer idle-timeout 2147483
dialer map ip 195.200.12.5 broadcast 4412961955
dialer-group 1
ppp authentication pap callin
ppp pap sent-username billGates password Linux

ip route 0.0.0.0 0.0.0.0 195.200.12.5
ip route 10.10.10.0 255.255.255.0 195.200.12.5
ip route 195.200.12.5 255.255.255.255 Dialer0

access-list 1 permit 10.10.10.0 0.0.0.255
dialer-list 1 protocol ip permit

line 1
script dialer dialnum
modem InOut
transport input all
stopbits 1
speed 19200
flowcontrol hardware


Explanation

Your network will look like this:

What you have is a Dialer interface on the router that issues the telephone number to the modem to dial into the local ISP, which the Serial port can do, since the Cisco 1601 uses a Serial port that can be defined as Synchronous or Asynchronous. The router's Dialer port is issued the same static IP address, and the ISP has configured their routers to forward all traffic to the 5 reserved addresses to this address used by your router's Dialer port.

The Cisco 1601 is configured with 5 static NAT translations, assigning one of the ISP's reserved addresses to one of the hosts on the local LAN. The Cisco 1601 is configured with 3 static routes to allow for correct routing: all traffic is by default routed to an upstream device at the ISP that either has a full routing table (a router) or will forward the traffic on to the appropriate routers (which the DNS host will do), a static route is defined that points all traffic destined for the local LAN back to this same upstream device (which honestly doesn't make sense, but is required to make this work), and finally a static route is configured that defines how to get to this upstream host.

What the IOS configs mean:

Monitoring Commands:

This won't work right if the static routes aren't defined correctly so make sure they are entered right, and that they are pointing to a real device upstream.

  • Other options for configuring NAT, such as dynamic address tranlsation, can be found on Cisco's web-page here.