Labs ICT
โญ Pro Login

DHCP

How your device automatically gets an IP address.

Automatic IP Configuration

When your device connects to a network, it needs an IP address, subnet mask, default gateway, and DNS server information. DHCP (Dynamic Host Configuration Protocol) provides all of this automatically โ€” no manual configuration required.

Without DHCP, you'd have to manually configure every device on every network you join. Imagine typing IP addresses every time you connect to a new Wi-Fi network. DHCP makes networking plug-and-play.

How DHCP Works (DORA Process)

DHCP uses a four-step process called DORA:


  Client                                          DHCP Server
    โ”‚                                                 โ”‚
    โ”‚โ”€โ”€โ”€โ”€ 1. DHCP Discover โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ†’โ”‚
    โ”‚     (broadcast: "Is there a DHCP server?")      โ”‚
    โ”‚                                                 โ”‚
    โ”‚โ†โ”€โ”€โ”€ 2. DHCP Offer โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”‚
    โ”‚     ("Yes! Here's an IP: 192.168.1.100")        โ”‚
    โ”‚                                                 โ”‚
    โ”‚โ”€โ”€โ”€โ”€ 3. DHCP Request โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ†’โ”‚
    โ”‚     ("I'll take 192.168.1.100")                 โ”‚
    โ”‚                                                 โ”‚
    โ”‚โ†โ”€โ”€โ”€ 4. DHCP Acknowledgment โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”‚
    โ”‚     ("Confirmed! Use it for 24 hours")          โ”‚

After this process, the client has:

  • An IP address
  • A subnet mask
  • A default gateway
  • DNS server addresses
  • A lease time (how long the IP is valid)

DHCP Lease and Renewal

DHCP addresses are leased, not permanently assigned. The lease has an expiration time (typically 24 hours). The client must renew the lease before it expires:


  Lease obtained โ”€โ”€โ”€โ”€ 50% elapsed โ”€โ”€โ”€โ”€ 87.5% elapsed โ”€โ”€โ”€โ”€ Lease expires
       โ”‚                    โ”‚                  โ”‚                โ”‚
       โ”‚                    โ”‚                  โ”‚                โ”‚
       โ”‚              T1: Try to         T2: Try to       Lose address
       โ”‚              renew with         renew with any    (must DORA again)
       โ”‚              original server    DHCP server

If the client can't renew before the lease expires, it must release the address and go through the DORA process again.

DHCP in Home Networks

Your home router is almost certainly running a DHCP server. When your phone or laptop connects to Wi-Fi, the router:

  1. Assigns a private IP address (like 192.168.1.100)
  2. Tells the device its own IP is the default gateway (192.168.1.1)
  3. Provides DNS server addresses (often its own or the ISP's)

This is why you can connect to any Wi-Fi network and it "just works" โ€” DHCP handles all the configuration automatically.

APIPA: The Fallback

If DHCP fails (no server available, network issues), most operating systems assign an APIPA (Automatic Private IP Addressing) address in the range 169.254.x.x. This allows devices on the same network to communicate locally, even without a DHCP server. But they won't have internet access.

๐Ÿงช Quick Quiz

What does DHCP automatically provide to devices?