Wednesday, February 13, 2013

DHCP Overview.


DHCP Overview Notes.

-Introduction.
-Format of a DHCP Message.
-DHCP Components.
-DHCP allocation Mechanisms and Allocation Process.
-Further Reading.

Introduction.

DHCP is an address allocation Protocol, it is used to assign devices an IP address and some other information . DHCP uses UDP as its transport Protocol. It uses a set of messages as a mechanism to request/assign addresses from Server to Client. 

DHCP messages from a client to a server are sent to the DHCP server port 67, and DHCP messages from a server to a client are sent to the DHCP Client Port 68.

Format of a DHCP Message.






DHCP Message Fields.

OP: Message OP Code  ( 1 = BOOTREQUEST , 2 = BOOTREPLY).

htype: Hardware Address Type ( Normally this refers to Ethernet). 

Hlen: Hardware address length ( In the case of Ethernet is 6 , referring to Ethernet MAC address 6 bytes).

hops: Optionally used by relay agents when booting via a relay agent. 

xid: Transaction ID.

secs: Filled in by client, seconds elapsed since client began address acquisition or renewal process.

flags: Flags ( this is used as a workaround for clients that cannot accept unicast datagrams before the TCP/IP stack is configured on the hosts).

ciaddr: Client IP address (this is only filled in if  client is in BOUND, RENEW, REBINDING state).

yiaddr: Client IP address , filled by the DHCP server in the address allocation process. 

siaddr: Ip of the next server to use on the allocation Process. 

giaddr: Relay agent IP address. 

chaddr: Client HW address (MAC).

sname: Optional server host name.

file: Boot file name.

options: options field.


DHCP Components.

DHCP Client:  This is the host trying to obtain an IP address.

DHCP Server: This is the server that responds to the clients Requests.

DHCP Relay Agent: This is a host or router that passes DHCP messages between different subnet/networks.

Binding: A binding is a collection of Configuration Parameters, including at least an IP address associated to a DHCP client.

DHCP Messages.

DHCPDISCOVER: Send by clients to locate available DHCP servers.

DHCPOFFER: Send by server to Client in response to DHCPDISCOVER, this includes the configuration parameters offered to the client.

DHCPREQUEST:  Send  by Client   to request the offered parameters from the server, offered in the DHCPOFFER message.

DHCPACK: Send by Server to client with the configuration parameters.

DHCPNAK: Send by Server to client indicating that the requested information ( by client) cannot be satisfied. 

DHCPDECLINE: Send by client to server indicating that the network address is in use.

DHCPRELEASE: Send by client to server to release the current address assigned by DHCP, cancelling remaining lease.

DHCPINFORM: Send by Client to server asking for local configuration parameters, client has already an Address configured.

DHCP allocation Mechanisms/Allocation Process.




Here is the process of how DHCP assigns network information to a Client.


  • 1 - The client Broadcast a DHCPDISCOVER message on his local Subnet.


  • 2 - Each Server responds with a DHCPOFFER Message, this includes the IP offerded (in the yiaddr field)  and any other configured parameter (options).


  • 3 - The client Broadcast a DHCPREQUEST message that includes the server identifier of the elected DHCP Server.


  • 4- The server Responds with a DHCPACK containing the configuration requested by the CLIENT on the DHCPREQUEST message.
  •        4a - If a server can not assign the request IP (because it has already assigned it) it responds        with a DHCPNAK.
  •       4b - If the client receives a DHCPNAK it restart the Proccess.


  • 5 - The client Verifies that the information in the DHCPACK message is valid, through the use of ARP.
  •  5a - In the case the IP address is already assigned, the client sends a DHCPDECLINE message.


Further Reading.

RFC 2131 : http://www.ietf.org/rfc/rfc2131.txt

DHCP Messages: http://technet.microsoft.com/en-us/library/cc977584.aspx

DHCP Options: http://technet.microsoft.com/en-us/library/cc977343.aspx

DHCP Pcap: http://wiki.wireshark.org/DHCP

DHCP Option 82: http://blog.ine.com/2009/07/22/understanding-dhcp-option-82/

DHCP Import Statement: http://blog.ine.com/2009/05/03/using-the-dhcp-import-statement/












1 comment: