# cat /etc/centos-release CentOS release 6.3 (Final) # uname -ri 2.6.32-279.11.1.el6.x86_64 x86_64 |
# dhcpd --version isc-dhcpd-4.1.1-P1 |
referred to http://www.madboa.com/geek/dhcp-failover/. ( many thx ! )
[ network topology ]
very simple
dhcpd ( primary ) -- L2SW -- Client
dhcpd ( secondary ) -----|
[ primary ]
# cat /etc/dhcp/dhcpd.conf # primary authoritative; ddns-update-style none; failover peer "dhcp-failover" { primary; # declare this to be the primary server address 192.168.102.100; # primary's IP port 647; peer address 192.168.102.101; # secondary's IP peer port 647; max-response-delay 30; max-unacked-updates 10; load balance max seconds 3; mclt 1800; split 128; } subnet 192.168.102.0 netmask 255.255.255.0 { option subnet-mask 255.255.255.0; option broadcast-address 192.168.102.255; option routers 192.168.102.1; option domain-name-servers 192.168.102.1; pool { failover peer "dhcp-failover"; default-lease-time 3600; # 1 hour max-lease-time 86400; # 1 day range 192.168.102.110 192.168.102.210; } } |
[ secondary ]
# cat /etc/dhcp/dhcpd.conf # secondary authoritative; ddns-update-style none; failover peer "dhcp-failover" { secondary; # declare this to be the secondary server address 192.168.102.101; # secondary's IP port 647; peer address 192.168.102.100; # primary's IP peer port 647; max-response-delay 30; max-unacked-updates 10; load balance max seconds 3; } subnet 192.168.102.0 netmask 255.255.255.0 { option subnet-mask 255.255.255.0; option broadcast-address 192.168.102.255; option routers 192.168.102.1; option domain-name-servers 192.168.102.1; pool { failover peer "dhcp-failover"; default-lease-time 3600; # 1 hour max-lease-time 86400; # 1 day range 192.168.102.110 192.168.102.210; } } |
- start DHCPD on both primar and secondary
# /etc/init.d/dhcpd start |
- syslog
cofirm failover state is normal.
primary
# egrep -i normal /var/log/messages dhcpd: failover peer dhcp-failover: I move from recover-done to normal dhcpd: failover peer dhcp-failover: peer moves from recover-done to normal |
secondary
# egrep normal /var/log/messages dhcpd: failover peer dhcp-failover: peer moves from recover-done to normal dhcpd: failover peer dhcp-failover: I move from recover-done to normal |
[ send a DHCP discover from the client ]
DHCPD has leased 192.168.102.160 to the Client.
Client # ifconfig eth0 | grep 'inet addr' inet addr:192.168.102.160 Bcast:192.168.102.255 Mask:255.255.255.0 |
the primary leased IP to the Client
log ( primary )
dhcpd: DHCPDISCOVER from 52:54:00:02:bf:f8 via eth0 dhcpd: DHCPOFFER on 192.168.102.160 to 52:54:00:02:bf:f8 via eth0 dhcpd: DHCPREQUEST for 192.168.102.160 (192.168.102.100) from 52:54:00:02:bf:f8 via eth0 dhcpd: DHCPACK on 192.168.102.160 to 52:54:00:02:bf:f8 via eth0 |
When configuring DHCP failover , at first DHCPD sets lease-time MCLT ( in this case 1800 seconds ) , not defai;t-lease-time ( in this case 3600 seconds )
The following is DHCP offer from the primary DHCP to the client.
lease time is 30 minutes , which is MCLT.
Your (client) IP address: 192.168.102.160 (192.168.102.160) Option: (t=51,l=4) IP Address Lease Time = 30 minutes <- MCLT Option: (51) IP Address Lease Time Length: 4 Value: 00000708 |
- Client will send a DHCP request to the primary to extend lease time after MCLT / 2 ( 15 minites )
# tshark -r primary2.pcap Running as user "root" and group "root". This could be dangerous. 1 0.000000 192.168.102.160 -> 192.168.102.100 DHCP DHCP Request - Transaction ID 0x1b1e6147 2 0.025141 192.168.102.100 -> 192.168.102.160 DHCP DHCP ACK - Transaction ID 0x1b1e6147 |
The following is DHCP ACK from the primary to the client
Option: (t=54,l=4) DHCP Server Identifier = 192.168.102.100 Option: (54) DHCP Server Identifier Length: 4 Value: C0A86664 Option: (t=51,l=4) IP Address Lease Time = 1 hour <- default-lease-time Option: (51) IP Address Lease Time Length: 4 Value: 00000E10 |
dhclient log ( client )
# cat /var/lib/dhclient/dhclient-eth0.leases lease { interface "eth0"; fixed-address 192.168.102.160; option subnet-mask 255.255.255.0; option routers 192.168.102.1; option dhcp-lease-time 1800; <- MCLT option dhcp-message-type 5; option domain-name-servers 192.168.102.1; option dhcp-server-identifier 192.168.102.100; option broadcast-address 192.168.102.255; renew 1 2012/11/04 10:00:01; rebind 1 2012/11/04 10:11:30; expire 1 2012/11/04 10:15:15; } lease { interface "eth0"; fixed-address 192.168.102.160; option subnet-mask 255.255.255.0; option routers 192.168.102.1; option dhcp-lease-time 3600; <- default lease time option dhcp-message-type 5; option domain-name-servers 192.168.102.1; option dhcp-server-identifier 192.168.102.100; option broadcast-address 192.168.102.255; renew 1 2012/11/04 10:24:14; rebind 1 2012/11/04 10:52:31; expire 1 2012/11/04 11:00:01; } |
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.