Apr 252012
 

Scenario:

If the DHCP server (Pri_DHCP) at Site A fails, the clients must get IP address from DHCP server (Bck_DHCP) at Site B. The backup DHCP must only be used in case the primary fails.

Logic: To solve this puzzle, there must be some kind of monitoring mechanism to figure out if the primary DHCP is available. For example we could use IP SLA monitor operation to check if the DHCP Service is working at the Primary DHCP Server.

A static route is attached to a tracking object which installs a route to null accordingly. The router R1 will not sent the DHCP requests to the ‘ip helper-address’ because of the lack of route to it. Now let’s try implementing it.

First we configure the IP SLA rule

R1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#ip sla monitor 1
R1(config-sla-monitor)#type dhcp
R1(config-sla-monitor)#type dhcp dest-ipaddr 10.0.100.253 source-ipaddr 10.0.100.1
R1(config-sla-monitor-dhcp)#frequency 10
R1(config-sla-monitor-dhcp)#exit
R1(config)#ip sla monitor schedule 1 life forever start-time now

Now lets check the SLA statistics

R1#sh ip sla monitor statistics 1
Round trip time (RTT)   Index 1
        Latest RTT: 2180 ms
Latest operation start time: *00:17:26.895 UTC Fri Mar 1 2002
Latest operation return code: OK
Number of successes: 28
Number of failures: 12
Operation time to live: Forever

The status of the SLA is OK, which means the DHCP server is available. Now we can use this SLA in combination with tracking a static route. When the SLA returns code OK, a static route must be installed to Sec_DHCP pointing towards null interface.

R1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#track 1 rtr 1
R1(config-track)#exit
R1(config)#ip route 10.0.0.253 255.255.255.255 Null0 track 1

Now when we check the routing table for static routes we must see the route via null interface installed

R1#sh ip route static
     10.0.0.0/8 is variably subnetted, 4 subnets, 2 masks
S       10.0.0.253/32 is directly connected, Null0

Now in this situation when the DHCP client sends a request and it also arrives at R1. R1 cannot use the ip-helper address because of the lack of route to it.

Now when we shut down the link from Pri_DHCP, the static route must be deleted.

Pri_DHCP#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Pri_DHCP(config)#int f0/0
Pri_DHCP(config-if)#sh

*Mar  1 00:24:55.415: %TRACKING-5-STATE: 1 rtr 1 state Up->Down
R1#sh ip route static

R1#

As the R1 does not have a route to the Backup DHCP, it will not relay the DHCP Discover to it.