Dynamic NAT

With dynamic NAT, you specify two sets of addresses on your Cisco router:

1. inside addresses that will be translated.
2. a pool of global addresses.

Unlike with static NAT, where you had to manually define a static mapping between a private and a public address, with dynamic NAT 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. It can be any address from the pool of global addresses. 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.

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 the 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

Here is an example.

dynamic nat example
Computer A requests a web resource from S1. Computer 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 Computer A.

In the example above we need to configure dynamic NAT. To do that, the following commands are required on R1:

1. To configure the router’s inside interface:

dynamic nat inside interface

2. To configure the router’s outside interface:

dynamic nat outside interface

3. To configure an ACL that has a list of the inside source addresses that will be translated:

dynamic nat acl

NOTE
The access list configured above matches all hosts from the 192.168.0.0/24 subnet.

 

4. To configure the pool of global IP addresses:

dynamic nat pool

The pool configured above consists of 5 addresses: 4.4.4.1, 4.4.4.2, 4.4.4.3, 4.4.4.4, and 4.4.4.5.

5. To enable dynamic NAT:

dynamic nat enabling

The command above instructs the router to translate all addresses specified in the access list 1 to the pool of global addresses called MY_POOL.

You can list all NAT translations using the show ip nat translations command:

dynamic nat show ip nat translations

In the example above, you can see that the private IP address of Computer A (192.168.0.2) has been translated to the first available global address (4.4.4.1).

NOTE
You can remove all NAT translations from the table by using the clear ip nat translation * command.
upravnik