Allocating External Addresses Dynamically
Problem
You want to dynamically select addresses from a pool.
Solution
You can configure the router to automatically select global addresses from a pool as they are required:
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 pool
NATPOOL 172.16.1.100 172.16.1.150
netmask
Router(config)#
255.255.255.0
ip nat inside source list
15
pool
Router(config)#
NATPOOL
interface
Router(config-if)#
FastEthernet 0/0
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)#
FastEthernet 0/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)#
Ethernet1/0
ip address
Router(config-if)#
172.16.1.2 255.255.255.0
ip nat outside
Router(config-if)#exit
Router(config)#end
Router#
Discussion
This example is similar to Recipe 21.1. The important
functional difference is that the internal devices will appear on the
outside with different global addresses. The first internal device
that makes an outbound connection will get the first address in the
range, 172.16.1.100
, the next one
will get the next address, 172.16.1.101
, and so forth.
You configure the range with the ip nat pool command:
Router(config)#ip nat pool
NATPOOL 172.16.1.100 172.16.1.150
netmask
Router(config)#
255.255.255.0
ip nat inside source ...
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.