Configuring Basic NAT Functionality
Problem
You want to set up Network Address Translation on your router.
Solution
In the simplest NAT configuration, all of your internal devices use the same external global address as the router’s external interface:
Router#configure terminal
Enter configuration commands, one per line. End with CNTL/Z. Router(config)#access-list
15
permit
Router(config)#
192.168.0.0 0.0.255.255
ip nat inside source list
15
interface
FastEthernet0/0
overload
Router(config)#interface
Router(config-if)#
FastEthernet0/2
ip address
Router(config-if)#
192.168.1.1 255.255.255.0
ip nat inside
Router(config-if)#exit
Router(config)#interface
Router(config-if)#
FastEthernet0/1
ip address
Router(config-if)#
192.168.2.1 255.255.255.0
ip nat inside
Router(config-if)#exit
Router(config)#interface
Router(config-if)#
Ethernet0/0
ip address
Router(config-if)#
172.16.1.5 255.255.255.252
ip nat outside
Router(config-if)#exit
Router(config)#end
Router#
Discussion
In this example, the router will rewrite that address of all of
the internal devices whose IP addresses are in the range 192.168.0.0/16
. When these internal devices
connect to devices on the outside of the network, they will all appear
to have the same source address as the external interface of the
router, 172.16.1.5
.
This example actually includes two internal interfaces and one external. You designate the internal interfaces with the ip nat inside command. You can have as many inside interfaces as you like:
Router(config)#interface ...
Get Cisco IOS Cookbook, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.