DHCP Client / Server Operation

Dynamic Host Configuration Protocol - http://www.faqs.org/rfcs/rfc2131.html

DHCP was first defined as a standards track protocol in RFC 1531 in October 1993, as an extension to the Bootstrap Protocol (BOOTP). The motivation for extending BOOTP was that BOOTP required manual intervention to add configuration information for each client, and did not provide a mechanism for reclaiming disused IP addresses.

DHCP process goes:

   1. BOOTP.Request (DHCP.Discover) - try to find a dhcpd server
       (Client sending BROADCAST UDP packet from 0.0.0.0:68 ->255.255.255.255:67)
   2. BOOTP.Reply (DHCP.Offer) - the dhcpd server send your client an offer that it will supply an ip
       (Server sending UNICAST UDP packet:    SERVER-IP:67 -> 255.255.255.255:68)
   3. BOOTP.Request (DHCP.Request) - client requests an ip from the dhcp server who offered.
       (Client sends BROADCAST packet: 0.0.0.0:68 -> 255.255.255.255:67 )
   4. BOOTP.Reply (DHCP.Ack) - the dhcpd server acknowledges the request with the ip information.
       (Server sending UNICAST ACK:      SERVER-IP:67 -> 255.255.255.255:68 )

 TCPDUMP:
11:35:14.150111 IP 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from 00:0a:e4:80:b5:39, length 300
11:35:14.207164 IP 10.188.237.1.67 > 10.188.237.3.68: BOOTP/DHCP, Reply, length 364
11:35:14.209536 IP 10.188.237.1.67 > 10.188.237.3.68: BOOTP/DHCP, Reply, length 364
11:35:18.209551 IP 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from 00:0a:e4:80:b5:39, length 300
11:35:18.245482 IP 10.188.237.1.67 > 10.188.237.3.68: BOOTP/DHCP, Reply, length 364
11:35:18.246855 IP 10.188.237.1.67 > 10.188.237.3.68: BOOTP/DHCP, Reply, length 364

DHCP Client is NOT ABLE to receive IP from DHCP Server
RFC describes :
DHCP clients are responsible for all message retransmission.  The client MUST adopt a retransmission strategy that incorporates a randomized exponential backoff algorithm to determine the delay between retransmissions.  The delay between retransmissions SHOULD be chosen to allow sufficient time for replies from the server to be delivered based on the characteristics of the internetwork between the client and the server.  For example, in a 10Mb/sec Ethernet internetwork, the delay before the first retransmission SHOULD be 4 seconds randomizedby the value of a uniform random number chosen from the range -1 to +1.  Clients with clocks that provide resolution granularity of less than one second may choose a non-integer randomization value.  The delay before the next retransmission SHOULD be 8 seconds randomized by the value of a uniform number chosen from the range -1 to +1.  The retransmission delay SHOULD be doubled with subsequent retransmissions up to a maximum of 64 seconds.  The client MAY provide an indication of retransmission attempts to the user as an indication of the progress of the configuration process.

DHCPD v5 example:


[root@forweb]# /sbin/dhcpcd -d -C resolv.conf -C mtu -G -C ntpd.conf -L fxp1
dhcpcd[1499]: version 5.2.11 starting
dhcpcd[1499]: fxp1: using hwaddr 00:11:25:65:1b:13
dhcpcd[1499]: fxp1: executing `/libexec/dhcpcd-run-hooks', reason PREINIT
dhcpcd[1499]: fxp1: executing `/libexec/dhcpcd-run-hooks', reason CARRIER
dhcpcd[1499]: fxp1: broadcasting for a lease
dhcpcd[1499]: fxp1: sending DISCOVER (xid 0x2e4d7d9b), next in 4.19 seconds
dhcpcd[1499]: fxp1: sending DISCOVER (xid 0x2e4d7d9b), next in 7.76 seconds
dhcpcd[1499]: fxp1: sending DISCOVER (xid 0x2e4d7d9b), next in 16.24 seconds
dhcpcd[1499]: fxp1: sending DISCOVER (xid 0x2e4d7d9b), next in 31.74 seconds
dhcpcd[1499]: timed out


30093 ms

DHCP Client IS ABLE to receive IP from DHCP Server:

[root@forweb]# /sbin/dhcpcd -d -C resolv.conf -C mtu -G -C ntpd.conf -L fxp1
dhcpcd[1212]: version 5.2.11 starting
dhcpcd[1212]: fxp1: using hwaddr 00:11:25:65:1b:13
dhcpcd[1212]: fxp1: executing `/libexec/dhcpcd-run-hooks', reason PREINIT
dhcpcd[1212]: fxp1: executing `/libexec/dhcpcd-run-hooks', reason CARRIER
dhcpcd[1212]: fxp1: broadcasting for a lease
dhcpcd[1212]: fxp1: sending DISCOVER (xid 0x6fb0d5a5), next in 4.75 seconds
dhcpcd[1212]: fxp1: offered 8.8.9.9 from 8.8.9.2(DHCP-IP)
dhcpcd[1212]: fxp1: sending REQUEST (xid 0x6fb0d5a5), next in 3.91 seconds
dhcpcd[1212]: fxp1: acknowledged 8.8.9.9 from 8.8.9.2(DHCP-IP)
dhcpcd[1212]: fxp1: checking for 8.8.9.9
dhcpcd[1212]: fxp1: sending ARP probe (1 of 3), next in 1.48 seconds
dhcpcd[1212]: fxp1: sending ARP probe (2 of 3), next in 1.89 seconds
dhcpcd[1212]: fxp1: sending ARP probe (3 of 3), next in 2.00 seconds
dhcpcd[1212]: fxp1: leased 8.8.9.9 for 172800 seconds
dhcpcd[1212]: fxp1: adding IP address 8.8.9.9/29
dhcpcd[1212]: fxp1: router 8.8.9.1 requires a host route
dhcpcd[1212]: fxp1: adding route to 8.8.9.10/29
dhcpcd[1212]: fxp1: adding host route to 8.8.9.1
dhcpcd[1212]: fxp1: writing lease `/var/db/dhcpcd-fxp1.lease'
dhcpcd[1212]: fxp1: executing `/libexec/dhcpcd-run-hooks', reason BOUND
dhcpcd[1212]: forking to background
dhcpcd[1212]: forked to background, child pid 1220

7118 ms


releasing:
[root@forweb]# /sbin/dhcpcd -k fxp1
dhcpcd[1223]: sending signal 1 to pid 1220
dhcpcd[1223]: waiting for pid 1220 to exit

Tools used: dhcpdump