Introduction
The digital age has made the internet an integral part of our daily lives, with the DHCP DORA process playing a pivotal role in how devices connect to networks effortlessly. This article breaks down the DHCP DORA process, a sequence critical for dynamic IP address allocation, into its four fundamental stages: Discover, Offer, Request, and Acknowledge.

By understanding this process, students can gain insights into the seamless connectivity that underpins our networked world, covering theoretical aspects and practical applications through detailed examples and code.
How DORA Works?
The DHCP DORA process ensures devices on a network can obtain IP addresses dynamically, fostering efficient network management and connectivity. Let's explore each stage in detail.
Discover
The Discover phase kicks off the process when a device (the DHCP client) broadcasts a message to find available DHCP servers. This DHCPDISCOVER message uses 0.0.0.0 as its source IP, aiming to reach any server that can offer an IP address.
Example Code:
from scapy.all import *
dhcp_discover = Ether(dst="ff:ff:ff:ff:ff:ff") / IP(src="0.0.0.0", dst="255.255.255.255") / UDP(sport=68, dport=67) / BOOTP(op=1) / DHCP(options=[("message-type", "discover"), "end"])
sendp(dhcp_discover)
This Python code snippet demonstrates creating and sending a DHCP Discover packet using Scapy, illustrating the initial step in the DORA process.
Offer
In response to the Discover message, DHCP servers on the network send back an Offer. This message includes a potential IP address for the client, along with other vital network configuration details. If there are multiple DHCP servers, the client might receive several offers.
Example Code:
def send_offer(client_mac):
offered_ip = "192.168.1.10"
dhcp_offer = Ether(dst=client_mac) / IP(src="192.168.1.1", dst="255.255.255.255") / UDP(sport=67, dport=68) / BOOTP(op=2, yiaddr=offered_ip) / DHCP(options=[("message-type", "offer"), ("server_id", "192.168.1.1"), "end"])
sendp(dhcp_offer)
This example outlines how a DHCP server might craft an Offer message, suggesting an IP address and necessary network settings to the client.
Request
Following the Offer, the client selects an IP address and broadcasts a DHCP Request message to indicate acceptance. This message also informs other servers that the client has made its selection, prompting them to retract their offers.
Example Code:
def send_request(server_ip, requested_ip):
dhcp_request = Ether(dst="ff:ff:ff:ff:ff:ff") / IP(src="0.0.0.0", dst="255.255.255.255") / UDP(sport=68, dport=67) / BOOTP(op=1) / DHCP(options=[("message-type", "request"), ("server_id", server_ip), ("requested_addr", requested_ip), "end"])
sendp(dhcp_request)
This code segment shows the formation of a DHCP Request packet, including the server's IP and the desired IP address.
Acknowledge
The Acknowledge stage concludes the process, with the DHCP server sending a DHCPACK message to confirm the IP address lease. This acknowledgment allows the client to start utilizing the assigned IP address.
Example Code:
def send_ack(client_mac, client_ip):
dhcp_ack = Ether(dst=client_mac) / IP(src="192.168.1.1", dst=client_ip) / UDP(sport=67, dport=68) / BOOTP(op=2) / DHCP(options=[("message-type", "ack"), "end"])
sendp(dhcp_ack)
This final snippet illustrates a server sending an Acknowledgment, cementing the IP lease agreement with the client.



