DHCP uses the client/server model. A DHCP client sends a message to a DHCP server to request configuration parameters, such as the IP address, subnet mask, and default gateway address. The DHCP server responds with a message carrying the requested configuration parameters. DHCP messages sent between clients and servers share an identical fixed format header and a variable format area for options.
Field |
Length |
Description |
---|---|---|
op |
1 byte |
Message operation code that specifies the message type. The options are as follows:
|
htype |
1 byte |
Hardware address type. For Ethernet, the value of this field is 1. |
hlen |
1 byte |
Hardware address length. For Ethernet, the value of this field is 6. |
hops |
1 byte |
Number of DHCP relay agents that have relayed this message. This field is set to 0 by a DHCP client. The value increases by 1 each time a DHCP message passes through a relay agent.
NOTE:
A maximum of 16 DHCP relay agents are allowed between a server and a client. If this number is exceeded, DHCP messages are discarded. |
xid |
4 bytes |
Transaction ID for this message exchange. A DHCP client generates a random number, which the client and server use to identify their message exchange. |
secs |
2 bytes |
Number of seconds elapsed since a DHCP client began to request an IP address. |
flags |
2 bytes |
The leftmost bit determines whether the DHCP server unicasts or broadcasts a DHCP Reply message. All remaining bits in this field are set to 0. The options are as follows:
|
ciaddr |
4 bytes |
Client IP address. The IP address can be an existing IP address of a DHCP client or an IP address assigned by a DHCP server to a DHCP client. During initialization, the client has no IP address, and the value of this field is 0.0.0.0.
NOTE:
The IP address 0.0.0.0 is an invalid address that is used only for temporary communication during system startup in DHCP mode. |
yiaddr |
4 bytes |
Client IP address assigned by the DHCP server. The DHCP server fills this field into a DHCP Reply message. |
siaddr |
4 bytes |
Server IP address from which a DHCP client obtains the startup configuration file. |
giaddr |
4 bytes |
Gateway IP address, which is the IP address of the first DHCP relay agent. If the DHCP server and client are located on different network segments, the first DHCP relay agent fills its own IP address into this field of the DHCP Request message sent by the client. The relay agent forwards the message to the DHCP server, which uses this field to determine the network segment where the client resides. The DHCP server then assigns an IP address on this network segment from an address pool. The DHCP server also returns a DHCP Reply message to the first DHCP relay agent. The DHCP relay agent then forwards the DHCP Reply message to the client.
NOTE:
If the DHCP Request message passes through multiple DHCP Relay agents before reaching the DHCP server, the value of this field remains as the IP address of the first DHCP relay agent. However, the value of the Hops field increases by 1 each time a DHCP Request message passes through a DHCP relay agent. |
chaddr |
16 bytes |
Client hardware address. This field must be consistent with the hardware type and hardware length fields. When sending a DHCP Request message, the client fills its hardware address into this field. For Ethernet, a 6-byte Ethernet MAC address must be filled in this field when the hardware type and hardware length fields are set to 1 and 6, respectively. |
sname |
64 bytes |
Server host name. This field is optional and contains the name of the server from which a client obtains configuration parameters. The field is filled in by the DHCP server and must contain a character string that ends with 0. |
file |
128 bytes |
Boot file name specified by the DHCP server for a DHCP client. This field is optional and is delivered to the client when the IP address is assigned to the client. The field is filled in by the DHCP server and must contain a character string that ends with 0. |
options |
Variable |
Optional parameters field. The length of this field must be at least 312 bytes. This field contains the DHCP message type and configuration parameters assigned by a server to a client, including the gateway IP address, DNS server IP address, and IP address lease. |
DHCP message types
Type |
Description |
---|---|
DHCP DISCOVER |
A DHCP Discover message is broadcast by a DHCP client to locate a DHCP server when the client attempts to access a network for the first time. |
DHCP OFFER |
A DHCP Offer message is sent by a DHCP server in response to a DHCP Discover message. A DHCP Offer message carries various configuration parameters. |
DHCP REQUEST |
A DHCP Request message is sent in the following conditions:
|
DHCP ACK |
A DHCP ACK message is sent by a DHCP server to acknowledge the DHCP Request message from a DHCP client. After receiving a DHCP ACK message, the DHCP client obtains the configuration parameters including the IP address. |
DHCP NAK |
A DHCP NAK message is sent by a DHCP server to reject the DHCP Request message from a DHCP client. For example, if a DHCP server cannot find matching lease records after receiving a DHCP Request message, it sends a DHCP NAK message indicating that no IP address is available for the DHCP client. |
DHCP DECLINE |
A DHCP Decline message is sent by a DHCP client to notify the DHCP server that the assigned IP address conflicts with another IP address. Then the DHCP client applies to the DHCP server for another IP address. |
DHCP RELEASE |
A DHCP Release message is sent by a DHCP client to release its IP address. After receiving a DHCP Release message, the DHCP server can assign this IP address to another DHCP client. |
DHCP INFORM |
A DHCP Inform message is sent by a DHCP client to obtain other network configuration parameters such as the gateway address and DNS server address after the DHCP client has obtained an IP address. |
DHCP options
Sub-field |
Length |
Description |
---|---|---|
Type |
1 byte |
Type of the message content |
Length |
1 byte |
Length of the message content |
Value |
Determined by the Length field value |
Message content |
The type value of the options field ranges from 1 to 255. Table 4 lists common DHCP options.
Options ID |
Description |
---|---|
1 |
Subnet mask |
3 |
Gateway address |
6 |
DNS address |
15 |
Domain name |
33 |
Group of classful static routes After a DHCP client receives DHCP messages with this option, it adds the classful static routes contained in the option to its routing table. In classful routes, masks of destination addresses are natural masks and cannot be used to divide subnets. If Option 121 exists, Option 33 is ignored. |
44 |
NetBIOS name |
46 |
NetBIOS object type |
50 |
Requested IP address |
51 |
IP address lease |
52 |
Additional option |
53 |
DHCP message type |
54 |
Server identifier |
55 |
Parameter request list The DHCP client uses this option to request specified configuration parameters |
58 |
Lease renewal time (Time1), which is 50% of the lease time |
59 |
Lease renewal time (Time2), which is 87.5% of the lease time |
60 |
Vendor information carried in DHCP messages sent from a DHCP client |
61 |
Client Identifier option |
66 |
TFTP Server Name option, which specifies the TFTP server name allocated to a client |
67 |
Bootfile Name option, which specifies the bootfile name allocated to a client |
82 |
Relay Agent Information option |
119 |
Domain Search List option, which is used to deliver the DNS suffix list |
120 |
SIP Server option, which is used to deliver the SIP server address. |
121 |
Group of classless routes After a DHCP client receives DHCP messages with this option, it adds the classless static routes contained in the option to its routing table. Classless routes can have destination address masks composed of any values and these masks can be used to divide subnets. |
125 |
Vendor-Identifying Vendor option |
143 |
Sets the redirection information option to specify the SZTP authentication server. |
The use of the options field differs depending on its function.
For more information about common DHCP options, see standard protocols.
Customized DHCP options
Some options are not defined in standard protocols. Option 43 and Option 82, which are customized options, are described as follows:
Option 43
Option 43 is called the vendor-specific information option. Figure 3 shows the Option 43 format.
DHCP servers and DHCP clients use Option 43 to exchange vendor-specific information. When a DHCP server receives a DHCP Request message with parameter 43 encapsulated in Option 55, the server encapsulates Option 43 in a DHCP Reply message and sends it to the DHCP client.
To implement extensibility and allocate more configuration parameters to DHCP clients, Option 43 supports sub-options, which are shown in Figure 3. Sub-options follow a similar format to that used for Options. They contain a Type, Length, and Value sub-field. In the Type sub-field, the value 0x01 indicates the Auto-configuration server (ACS) parameter, the value 0x02 indicates the SP ID, and the value 0x80 indicates the Preboot execution environment (PXE) server address.
If a device functions as a DHCP client, it can obtain the following information using Option 43:
ACS parameters, including the uniform resource locator (URL), user name, and password
SP ID that the Customer Premises Equipment (CPE) notifies the ACS of so that the ACS can select configuration parameters from the specified SP
PXE server address, which is used by a DHCP client to obtain the Bootfile or control information from the PXE server
Option 82
The Option 82 field is called the DHCP relay agent information field. It records the location of a DHCP client. A DHCP relay agent or a DHCP snooping-enabled device appends the Option 82 field to a DHCP Request message sent from a DHCP client and forwards the message to a DHCP server.
Servers use the Option 82 field to learn the location of DHCP clients, implement client security and accounting, and make parameter assignment policies, allowing for more flexible address allocation.
The Option 82 field contains a maximum of 255 sub-options. If the Option 82 field is defined, at least one sub-option must be defined.
The content of the Option 82 field is not uniformly defined, and vendors fill in the Option 82 field as needed.
Type1: This is the Telecom format of Option 82.
Type2: This is the NMS format of Option 82.
Cn-telecom: This is the Option 82 format defined by cn-telecom.
Self-define: This is the user-defined format of DHCP Option 82.