Unlike with static NAT, where you had to manually define a static mapping between a private and public address, dynamic NAT does the mapping of a local address to a global address happens dynamically. This means that the router dynamically picks an address from the global address pool that is not currently assigned. The dynamic entry stays in the NAT translations table as long as the traffic is exchanged. The entry times out after a period of inactivity and the global IP address can be used for new translations.
With dynamic NAT, you need to specify two sets of addresses on your Cisco router:
- the inside addresses that will be translated
- a pool of global addresses
To configure dynamic NAT, the following steps are required:
1. configure the router’s inside interface using the ip nat inside command
2. configure the router’s outside interface using the ip nat outside command
3. configure an ACL that has a list of the inside source addresses that will be translated
4. configure a pool of global IP addresses using the ip nat pool NAME FIRST_IP_ADDRESS LAST_IP_ADDRESS netmask SUBNET_MASK command
5. enable dynamic NAT with the ip nat inside source list ACL_NUMBER pool NAME global configuration command
Consider the following example:
Host A requests a web resource from a internet server S1. Host A uses its private IP address when sending the request to router R1. Router R1 receives the request, changes the private IP address to one of the available global addresses in the pool and sends the request to S1. S1 responds to R1. R1 receives the response, looks up in its NAT table and changes the destination IP address to the private IP address of Host A.
To configure dynamic NAT, the following commands are required on R1:
1. First we need to configure the router’s inside and outside NAT interfaces::
2. Next, we need to configure an ACL that will include a list of the inside source addresses that will be translated:
The access list configured above matches only the 10.0.0.100 IP address.
3. We need to configure the pool of global (public) IP addresses:
The pool configured above consists of 3 addresses: 22.214.171.124, 126.96.36.199, and 188.8.131.52.
4. Lastly, we need to enable dynamic NAT:
The command above tells the router to translate all addresses specified in the access list 1 to the pool of global addresses named MY POOL.
You can list all NAT translations using the show ip nat translations command:
In the picture above you can see that the translation has been made between the Host A’s private IP address (Inside local, 10.0.0.100) to the first available public IP address from the pool (Inside global, 184.108.40.206).