# DHCP - Dynamic Host Configuration Protocol
## What is DHCP
DHCP, the Dynamic Host Configuration Protocol, is a network management protocol used to automatically assign IP addresses and other network configuration parameters to devices when they connect to a network. Without DHCP, a network administrator would need to manually configure an IP address, subnet mask, default gateway, and DNS server address on every device. In networks with many devices, this manual configuration is impractical. DHCP automates this process, making it easy to add devices to a network and ensuring correct configuration.
## DHCP Operation - DORA Process
The DHCP process follows four steps, often remembered by the acronym DORA. In the Discover step, a new device with no IP address broadcasts a DHCP Discover message to the entire local network asking for IP address configuration. Because the device has no IP address yet, it uses 0.0.0.0 as the source address and 255.255.255.255 as the broadcast destination address. In the Offer step, one or more DHCP servers that receive the discover message respond with a DHCP Offer message containing an available IP address, subnet mask, default gateway, DNS server addresses, and a lease duration. In the Request step, the client broadcasts a DHCP Request message indicating which offer it accepts. Sending this as a broadcast informs all DHCP servers of the client's choice, allowing servers that made offers that were not accepted to return their offered addresses to the available pool. In the Acknowledge step, the chosen DHCP server sends a DHCP Acknowledge message confirming the address assignment and providing all the configuration parameters. The client configures its network interface with the provided information.
## DHCP Lease
An IP address assigned by DHCP is not permanent but is leased for a specified period of time called the lease duration. Before the lease expires, the client sends a renewal request to the DHCP server to extend the lease and continue using the same IP address. If the renewal is approved, the lease is extended. If the server cannot be reached, the client continues to use the address until the lease expires, then attempts to obtain a new address.
## DHCP Options
In addition to the IP address, subnet mask, default gateway, and DNS servers, DHCP can provide many other configuration parameters called options. These include the domain name, NTP server addresses, WINS server addresses, vendor-specific information, and many other parameters that devices might need.
## DHCP Relay Agent
DHCP uses broadcast messages for the discover and request steps, but broadcasts do not cross router boundaries. This means a DHCP server can only serve devices on its directly connected network. A DHCP relay agent solves this problem. The relay agent is configured on each network segment. When it receives a DHCP broadcast, it converts it to a unicast message and forwards it to the DHCP server at a configured address. The DHCP server sends its response back to the relay agent, which forwards it to the client.Back to Course