codingstuff.io
ExploreTutorialsProblemsCS Subjects
Get Started
ExploreTutorialsProblemsCS Subjects
Get Started
codingstuff.io

Master the art of building software through interactive tutorials, real-world problems, and guided projects.

Pune, Maharashtra, India

codingstuffmail@gmail.com

Product

  • Explore
  • Tutorials
  • Problems
  • CS Subjects

Company

  • About
  • Contact
  • Privacy Policy
  • Terms & Conditions
  • Sitemap

© 2026 codingstuff.io. All rights reserved.

Built with ❤️ for developers everywhere

/
/
All Subjects
🌐

Computer Networks

26 chapters

1Network Topologies & LAN/WAN2Network Devices (Hub, Switch, Router)3OSI Reference Model4OSI Model & TCP/IP Suite5TCP/IP Protocol Suite6Switching Techniques (Circuit, Packet)7Data Link: Framing & Error Detection8Error Correction (Hamming Code)9Flow Control (Stop-and-Wait, Sliding Window)10MAC: CSMA/CD & CSMA/CA11Network Layer & Routing12IP Addressing (IPv4, IPv6)13Subnetting & CIDR14Routing Algorithms (Distance Vector, Link State)15ARP, ICMP, and NAT16DHCP Protocol17Transport Layer Services18Transport Layer: UDP19Transport Layer: TCP & 3-Way Handshake20TCP Congestion Control21Application Layer: DNS & HTTP22Application Layer: SMTP & FTP23Socket Programming Basics24Wireless Networks & Wi-Fi Standards25VLANs & Spanning Tree Protocol26Network Security & Cryptography
SubjectsComputer Networks

DHCP Protocol

Updated 2026-05-01
2 min read

DHCP Protocol

The Dynamic Host Configuration Protocol (DHCP) automatically assigns IP addresses and other network configuration parameters (subnet mask, default gateway, DNS server) to devices when they connect to a network. Without DHCP, every device on a network would need to be manually configured—an impossibility in networks with thousands of devices.

1. The DORA Process

DHCP uses a 4-step handshake (DORA):

1. DHCP Discover (Client broadcasts)

When a device connects to a network, it has no IP address. It broadcasts a DHCP Discover message to the entire local network on UDP port 67, asking "Is there a DHCP server here?"

2. DHCP Offer (Server responds)

The DHCP server receives the broadcast and responds with a DHCP Offer, proposing an available IP address along with the lease duration, subnet mask, gateway, and DNS server addresses.

3. DHCP Request (Client accepts)

The client broadcasts a DHCP Request, formally requesting the offered IP address. Broadcasting ensures that if multiple DHCP servers responded, the others know their offer was declined.

4. DHCP Acknowledgment (Server confirms)

The DHCP server confirms the assignment with a DHCP ACK. The client now configures its network interface with the assigned parameters.

2. IP Address Leasing

DHCP does not permanently assign IP addresses. Each assignment has a Lease Duration (e.g., 24 hours). The client must renew the lease before it expires. If the client disconnects without releasing the address, the lease eventually expires and the IP is returned to the pool.

3. DHCP Relay Agent

DHCP uses broadcast messages, which do not cross router boundaries. If the DHCP server is on a different subnet, a DHCP Relay Agent (configured on the router) intercepts the broadcast and forwards it as a unicast packet to the DHCP server on the remote subnet.

4. Static vs Dynamic Assignment

  • Dynamic: IP addresses are assigned from a pool and may change on each connection.
  • Static (Reserved): The DHCP server is configured to always assign the same IP to a specific device based on its MAC address. Used for servers and printers that need a consistent address.


PreviousARP, ICMP, and NATNextTransport Layer Services

Recommended Gear

ARP, ICMP, and NATTransport Layer Services