Cisco IOS | Nat a subnet to external IP address

It might happen some times that you need to translate a complete subnet to an external IP address. This can be useful if you use multiple companies behind a network device. To accomplish this result you can use on a cisco IOS the following setup.

ip access-list extended natlist-vlan<vlan-tag>
 permit ip <ip range> 0.0.0.255 any

ip nat pool nat-vlan<vlan-tag> <external ip address> <external ip address> prefix-length XX (e.a. 29)
ip nat inside source list natlist-vlan<vlan-tag> pool nat-vlan<vlan-tag> overload

The result will be that a device form the selected subnet will be visible as a different external IP address than the original IP address. For example, your main IP address is 1.1.1.20 but you want to have a different IP address like 1.1.1.21 then you can use the command.

ip access-list extended natlist-vlan21
 permit ip 21.21.21.0 0.0.0.255 any

ip nat pool nat-vlan21 1.1.1.21 1.1.1.21 prefix-length 29
ip nat inside source list natlist-vlan21 pool nat-vlan21 overload

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.