Introduction to DHCPv4 Message Format

As discussed in the previous lesson, DHCPv4 clients and servers exchange messages to exchange IP address information. The format of all DHCPv4 messages is common and based on the BOOTP specification.

The DHCP v4 uses UDP port numbers 67 and 68 with BOOTP.  Post 68 is the DHCPv4 source port number, while port 67 is the destination port. DHCP messages contain a special option in the option field that differentiates them from BOOTP messages.  The figure below illustrates the DHCPv4 message format.

  • OP Code –This is an 8-bit field specifying the message type. It has two different states: a value of 1 indicates a REQUEST message, and a value of 2 indicates a REPLY message.
  • Hardware Type– This is also an 8-bit field that identifies the type of hardware used in the network. This field identifies the hardware address type.
  • Hardware Address Length—This is another 8-bit field to identify a DHCP client’s address length.
  • Hops—This field counts and controls the relay agent and message forwarding. This client set the field to 0 before transmitting a request.
  • Transaction Identifier– The client uses this field to match the request with replies received from DHCPv4 servers.
  • Seconds– This field identifies the elapsed time in seconds since a client began attempting to get the IP address on a lease basis or renew a previous lease. The DHCPv4 servers use this field to prioritize replies when multiple client requests are outstanding.
  • Flags—As shown in the figure, this is a 16-bit field of the DHCPv4 message. A client without an IPv4 address uses this field when sending a request. Only one bit (leftmost) out of 16 bits is used: the broadcast flag. If this flag is set to 1, the DHCP server sends a reply by broadcast. The remaining bits of the flags field are reserved for future use.
  • CIADDR—This is the client IP address field used during lease renewal when the client’s address is valid and usable. The client puts its own IPv4 address in this field if it has a valid IPv4 address while in the bound state; otherwise, it sets the field to 0.
  • YIADDR – ‘your’ (client) IPv4 address assigned by the server to the client.
  • SIADDR—This is the IP address of the following server for the client to use in the configuration and bootstrap process, which may be the same server sending this reply. The sending server always includes its IPv4 address in a particular field called the Server Identifier DHCPv4 option.
  • GIADDR– This is a gateway or relay agent IP address. The IP address may be the interface IP of the relay agent through which the DHCP message was received. It facilitates communications of DHCPv4 requests and replies between the client and a server that are on different subnets or networks.
  • CHADDR – This field matches responses from servers with previously transmitted requests and specifies the physical layer of the client system.
  • Server Name– Used by the server sending a DHCPOFFER or DHCPACK message. The server may optionally put its name in this field. This can be a simple text nickname or a DNS domain name, such as dhcpserver.netacad.net.
  • SNAME: Server hostname, sending a DHCPOFFER or DHCPACK message. This can be a simple text nickname or a DNS domain name.
  • Boot Filename– The client uses a boot file name optionally to request a particular type of boot file in a DHCPDISCOVER message and a server also used this in a DHCPOFFER to fully specify a boot file directory and filename
  • DHCP Options– This is an optional field that holds several parameters required for basic DHCP operation. The length of this field is not fixed. Both the client and server use this field.