Automating IPs with DHCP

Ch. 6 of 1014 mins4 Tasks

Say goodbye to tedious manual IP configurations. Discover how the DHCP DORA process automatically distributes IP addresses, subnet masks, and gateways across the office.

Track Series

Chapters in this Track (Ch. 6 of 10)

6Automating IPs with DHCP
14m

In our previous chapters, you manually assigned static IP addresses like 192.168.1.10 and 192.168.1.20 into workstation network adapters. When managing two computers on a desk, typing static numbers takes only a few seconds. But imagine managing an office floor with two hundred laptops, smartphones, printers, and meeting room screens. If a network technician had to visit every desk, open network adapter settings, and punch in four decimal numbers by hand, the administrative overhead would be immense.

Worse yet, manual configuration inevitably leads to human error. Two employees might accidentally be given the identical address 192.168.1.45, triggering an IP Address Conflict that disconnects both computers from the network. To eliminate this chaos, modern networks rely on a silent automation protocol: Dynamic Host Configuration Protocol (DHCP).

The DORA Four-Way Handshake

When a newly unboxed laptop plugs into an office Ethernet wall jack or connects to Wi-Fi, its network adapter has no IP address, no subnet mask, and no idea where the default gateway lives. To bootstrap itself, the client initiates a four-step conversation known by the acronym DORA:

  1. Discover (Client Broadcast): The client transmits a DHCPDISCOVER packet. Because it does not yet have an IP address, its source IP is 0.0.0.0. Because it does not know where the DHCP server is, it broadcasts the frame to destination IP 255.255.255.255 on UDP port 67. The central switch floods this broadcast to all ports.
  2. Offer (Server Unicast/Broadcast): The DHCP server receives the discovery frame, looks inside its address pool (called a DHCP Scope), reserves an available IP (such as 192.168.1.100), and transmits a DHCPOFFER back to the client MAC address.
  3. Request (Client Acceptance): If multiple DHCP servers replied, the client chooses the first valid offer and broadcasts a DHCPREQUEST: "Thank you! I would like to lease 192.168.1.100 from server 192.168.1.50." Broadcasting this request politely notifies other servers that their offers were declined and can be returned to their available pools.
  4. Acknowledge (Server Confirmation): The chosen server replies with a DHCPACK (Acknowledgment) frame containing the final lease duration, subnet mask (255.255.255.0), default gateway (192.168.1.1), and local DNS resolver (192.168.1.53). The client commits these parameters to its network card and begins communication immediately.
Stage Packet Type Sender & Destination Payload Details
D DHCPDISCOVER Client (0.0.0.0) → Broadcast (255.255.255.255) Queries the network: "Is there a DHCP server here?"
O DHCPOFFER Server (192.168.1.50) → Client Proposes IP lease: 192.168.1.100, mask, and lease time.
R DHCPREQUEST Client → Broadcast Confirms: "I accept IP 192.168.1.100 from Server 192.168.1.50."
A DHCPACK Server → Client Final lease confirmation with Gateway and DNS settings.
Port Numbers in DHCP

DHCP operates over User Datagram Protocol (UDP). The DHCP server listens on UDP Port 67, while bootstrapping clients listen on UDP Port 68. Using distinct port numbers ensures client broadcasts do not interfere with server responses.

Lease Time and Address Recycling

Unlike a static IP, a DHCP address is never permanently owned by the client. It is granted as a temporary Lease (typically 24 hours on office networks, or 2 hours on public Wi-Fi). When half the lease time expires (the T1 renewal timer at 50%), the client automatically contacts the server to renew its lease. If an employee leaves the office and disconnects their laptop, the lease expires and the server returns that IP to the pool, ready to be reassigned to tomorrow's visitor.

If the original server does not respond at the 50% mark, the client keeps working normally. When the clock hits 87.5% (the T2 rebind timer), the client broadcasts an emergency request to see if any secondary DHCP server is available. If the lease fully expires without an answer, the client drops the address and starts fresh with a new DORA handshake.

Field Incident: The Rogue Wi-Fi Router

One of the most famous troubleshooting incidents in IT happens when an employee brings an unauthorized home wireless router from home and plugs its LAN port into an office wall jack. That home router runs its own DHCP server, handing out wrong IP addresses and bad gateways to neighboring computers.

Suddenly, half the accounting team loses internet access because their computers received a lease from the rogue box instead of the corporate server. Understanding how the DORA handshake works allows engineers to track down the offending MAC address and configure DHCP Snooping on the switch to block unauthorized replies.

The Bridge to the Outside World

Thanks to DHCP, every computer in our office now has an IP address and knows its local subnet. But what happens when an employee wants to open Google, check weather reports, or connect to a cloud service outside the building? Local switches cannot help them leave the office.

Notice that along with your IP address, the DHCP server also handed you a Default Gateway address (192.168.1.1). In our next chapter, we will see how this gateway router takes your packets, reads their destination, and acts as the official exit door to the outside world.

Hands-On Practice Checklist

Progress:0 / 4

Perform actions on the practice lab canvas on the right. Tasks automatically check off as you connect cables and run commands.

Task 1: Inspect DHCP Server Pool Parameters

Click on Central Server in the canvas, open the Services tab, select DHCP, and review the active IP pool range (192.168.1.100 - 192.168.1.150) and Gateway.

Task 2: Switch Workstation PC-1 to DHCP Mode

Click Workstation PC-1, navigate to the Config tab, select "DHCP Client (Auto)", and click the "Request DHCP" button to trigger the DORA handshake.

Task 3: Verify Dynamic IP and Gateway Binding

Confirm that PC-1 received IP address 192.168.1.100, Subnet Mask 255.255.255.0, and Default Gateway 192.168.1.1 directly from the server.

Task 4: Test Connectivity to DHCP Server

Open the Terminal tab on PC-1 and run "ping 192.168.1.50" to verify that two-way communication between workstation and server is working.