2.4. DHCP Protocol

2.4.1. Introduction

Dynamic Host Configuration Protocol (DHCP) is a network protocol for local area networks, located in the application layer of the OSI model, and works using the UDP protocol. It is mainly used to automatically assign IP addresses to users and facilitate unified management by administrators.

The DHCP server uses 67/udp and the client uses 68/udp. DHCP operation is divided into four basic processes, namely requesting an IP lease, providing an IP lease, selecting an IP lease, and confirming an IP lease. After the client obtains an IP address, it can send an ARP request to avoid IP conflicts caused by overlapping DHCP server address pools.

2.4.2. DCHP message format

0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|     op (1)    |   htype (1)   |   hlen (1)    |   hops (1)    |
+---------------+---------------+---------------+---------------+
|                            xid (4)                            |
+-------------------------------+-------------------------------+
|           secs (2)            |           flags (2)           |
+-------------------------------+-------------------------------+
|                          ciaddr  (4)                          |
+---------------------------------------------------------------+
|                          yiaddr  (4)                          |
+---------------------------------------------------------------+
|                          siaddr  (4)                          |
+---------------------------------------------------------------+
|                          giaddr  (4)                          |
+---------------------------------------------------------------+
|                          chaddr  (16)                         |
+---------------------------------------------------------------+
|                          sname   (64)                         |
+---------------------------------------------------------------+
|                          file    (128)                        |
+---------------------------------------------------------------+
|                          options (variable)                   |
+---------------------------------------------------------------+