Stateful NAT allows you to configure routers to synchronise their NAT tables. It is useful in situations where you have redundant gateways and need the traffic to flow uninterrupted in the event of a failover.
ip nat Stateful id 1
redundancy HSRP_IN
mapping-id 1
as-queuing disable
protocol udp
We now need to create the NAT and HSRP settings on the interfaces. Obviously we are setting the NAT inside and outside. The HSRP is tracking the opposite interface so that the priority is reduced if it fails triggering a failover.
interface FastEthernet0/0
ip address 10.44.0.2 255.255.255.0
ip nat inside
ip virtual-reassembly
duplex auto
speed auto
standby ip 10.44.0.1
standby priority 110
standby preempt
standby name HSRP_IN
standby track FastEthernet0/1 20
interface FastEthernet0/1
ip address 10.159.12.152 255.255.255.0
ip nat outside
ip virtual-reassembly
duplex auto
speed auto
standby ip 10.159.12.151
standby priority 110
standby preempt
standby track FastEthernet0/0 20
Next we setup a NAT rule to translate the correct traffic. Note that the mapping-id number in the inside NAT statement refers to our mapping-id we setup earlier.
access-list 100 permit ip 10.44.0.0 0.0.0.255 any
ip nat pool test 10.159.12.154 10.159.12.155 netmask 255.255.255.0
ip nat inside source list 100 pool test mapping-id 1 overload
You need to put the config on both the routers. The stateful information is transferred on the HSRP interfaces.
If you issue a show nat translations you will now see that the NAT translations are synchronised between the two routers.
If a link goes down the HSRP fails over and due to the NAT tables already being synced the traffic can continue to flow uninterrupted. The only issue we did notice was that when the failed link came up after a stateful failover the traffic flow stopped. We determined that this was because whilst the link was down the NAT sync was not able to work. When the link is restored the HSRP switchover happens before the stateful info can be transferred. To fix this we need to introduce a delay to the HSRP failover to allow the routers enough time to sync up before switching over.
The first command below prevents the HSRP process from starting up until the timer has expired. The second prevents the router from preempting the active router until the timer expires.
standby delay minimum 60 reload 60
standby 1 preempt delay minimum 60 reload 60 sync 60
The first thing to setup is the stateful NAT mapping id. This determines how the routers communicate their NAT information. You can configure the synchronisation to use either UDP or TCP. The redundancy name should be used in the HSRP configuration later.
ip nat Stateful id 1
redundancy HSRP_IN
mapping-id 1
as-queuing disable
protocol udp
We now need to create the NAT and HSRP settings on the interfaces. Obviously we are setting the NAT inside and outside. The HSRP is tracking the opposite interface so that the priority is reduced if it fails triggering a failover.
interface FastEthernet0/0
ip address 10.44.0.2 255.255.255.0
ip nat inside
ip virtual-reassembly
duplex auto
speed auto
standby ip 10.44.0.1
standby priority 110
standby preempt
standby name HSRP_IN
standby track FastEthernet0/1 20
interface FastEthernet0/1
ip address 10.159.12.152 255.255.255.0
ip nat outside
ip virtual-reassembly
duplex auto
speed auto
standby ip 10.159.12.151
standby priority 110
standby preempt
standby track FastEthernet0/0 20
Next we setup a NAT rule to translate the correct traffic. Note that the mapping-id number in the inside NAT statement refers to our mapping-id we setup earlier.
access-list 100 permit ip 10.44.0.0 0.0.0.255 any
ip nat pool test 10.159.12.154 10.159.12.155 netmask 255.255.255.0
ip nat inside source list 100 pool test mapping-id 1 overload
You need to put the config on both the routers. The stateful information is transferred on the HSRP interfaces.
If you issue a show nat translations you will now see that the NAT translations are synchronised between the two routers.
If a link goes down the HSRP fails over and due to the NAT tables already being synced the traffic can continue to flow uninterrupted. The only issue we did notice was that when the failed link came up after a stateful failover the traffic flow stopped. We determined that this was because whilst the link was down the NAT sync was not able to work. When the link is restored the HSRP switchover happens before the stateful info can be transferred. To fix this we need to introduce a delay to the HSRP failover to allow the routers enough time to sync up before switching over.
The first command below prevents the HSRP process from starting up until the timer has expired. The second prevents the router from preempting the active router until the timer expires.
standby delay minimum 60 reload 60
standby 1 preempt delay minimum 60 reload 60 sync 60
Comments
Post a Comment