DHCP – Dynamic Host Configuration Protocol in a TCP / IP network.
I will describe the possible types of DHCP messages:
DHCPDISCOVER — customer request for addresses.
DHCPOFFER — the server’s offer to get the address.
DHCPREQUEST — a client request for an address (suggested by the server in DHCPOFFER), as well as extending the lease of the IP address..
DHCPACK — server confirmation of the issuance of the address.
DHCPDECLINE — the client’s refusal to receive the proposed address (for example, when a client sees that the proposed IP address is already being used by someone on the network).
DHCPNAK — failure of the server to issue the requested address, usually after that the client sends DHCPDISCOVER.
DHCPRELEASE — notification of the client about the release of the address.
DHCPINFORM — customer request for additional parameters.
I will describe the process of successfully obtaining a DHCP client IP address from a DHCP server:
1) DHCP client from IP address 0.0.0.0 through UDP port 67 sends to network IP address 255.255.255.255 broadcast message DHCPDISCOVER “I want to get IP address”.
2) A DHCP server or several DHCP servers, if there are several of them, receive this message and reply to the client from their IP via UDP port 68 with the message DHCPOFFER “I propose an IP address”. The message is sent to the broadcast address 255.255.255.255 or the gateway address if the client is on another network.
3) The DHCP client receives this message or several messages and responds from the IP address 0.0.0.0 to only one DHCP server with the DHCPREQUEST message “Yes, I want this IP address”.
4) The DHCP server sends a DHCPACK message “I assign you this IP address” in response.
Since the IP address has a lease time after which it is released and the DHCP server can issue it for example to another client, the DHCP clients usually request the renewal with a DHCPREQUEST message and receive a DHCPACK response.
I will describe the composition of the DHCP message:
op (type of message, for example DHCPDISCOVER, size 1 byte)
htype (type of hardware address, size 1 byte)
hlen (length of hardware address, for example 6 for MAC address, size 1 byte)
hops (the number of relay agents between the server and the client, the clients set the value to 0, the size of 1 byte)
xid (Transaction ID, generated by the client at the beginning, size 4 bytes)
secs (the elapsed time in seconds from the time of requesting the receipt of the address can be 0, the size of 2 bytes)
flags (field for flags, size 2 bytes)
ciaddr (The IP address of the client, for example, if it requests a lease extension, the size is 4 bytes)
yiaddr (IP address offered by the server to the client, size 4 bytes)
siaddr (Server IP address, size 4 bytes)
giaddr (IP address of the relay agent, size 4 bytes)
chaddr (hardware client address (MAC), size 16 bytes)
sname (server name, 64 bytes)
file (the name of the boot file, can be used to boot the operating system over the network, 128 bytes)
options (additional options)
See also my articles:
- IPTables rules for DHCP
- Installing and Using dhcpdump
- Installing and configuring isc-dhcp-server in Ubuntu
- Testing a DHCP server with dhcpperf