Skip to content

Try “polymorphism”, “TCP handshake” or “git rebase”.

    Computer Basics / Networking 1: Addresses and Routing

    DHCP: Getting an Address Automatically

    You check into a hotel. You don't pick a room number yourself — you ask reception, and they hand you a

    Chapter 9 of 112 min read

    The Plain Picture#

    You check into a hotel. You don't pick a room number yourself — you ask reception, and they hand you a key card with your room number, the Wi-Fi password and the breakfast timing. The card expires at checkout.

    The Real Name#

    DHCP (Dynamic Host Configuration Protocol) gives a device, when it joins a network:

    for a limited time called a lease (hours or days). The device renews the lease before it expires.

    Under the Hood#

    Your laptop has no address yet, so it can't send a normal packet to anyone. It uses broadcasts (Chapters 3 and 6). The four-step exchange is often remembered as DORA:

      Laptop (no IP yet)                                       DHCP server (usually your router)
           │  1. DISCOVER  (broadcast) "Any DHCP server here?"        │
           │ ───────────────────────────────────────────────────────▶ │
           │  2. OFFER     "You can have 192.168.1.37 for 24 hours"   │
           │ ◀─────────────────────────────────────────────────────── │
           │  3. REQUEST   (broadcast) "I'll take 192.168.1.37"       │
           │ ───────────────────────────────────────────────────────▶ │
           │  4. ACK       "Confirmed. Gateway 192.168.1.1, DNS ..."  │
           │ ◀─────────────────────────────────────────────────────── │

    If no server answers, the device gives itself a 169.254.x.x address (Chapter 6) — and has no internet.

    Servers in data centres usually get their address from DHCP too, even in the cloud — or they have a static (fixed, manually set) address.

    Check yourself

    3 questions
    1

    Name four things DHCP gives a device.

    Show answer

    IP address, subnet, default gateway, DNS servers (plus a lease time).

    2

    What does DORA stand for?

    Show answer

    Discover, Offer, Request, Acknowledge.

    3

    Why does the laptop use broadcasts for DHCP?

    Show answer

    It doesn't have an IP address yet and doesn't know the server's, so it can only shout to everyone on the LAN.