linuxlab.io
Tutorials▾
  • Linux & networking
    File system, processes, TCP/IP, BGP and OSPF
    →
  • Terraform & IaC
    HCL, state, plan/apply on a LocalStack sandbox
    →
  • Git & GitHub
    Object model, plumbing, branching, GitHub Actions
    →
All tutorials →
PricingAboutSign inCreate account
/
Intro
Lessons
Footer
linuxlab-TutorialsPricingAboutPrivacy & cookies
Copyright © 2026 LinuxLab. All rights reserved.
linuxlab.io
Tutorials▾
  • Linux & networking
    File system, processes, TCP/IP, BGP and OSPF
    →
  • Terraform & IaC
    HCL, state, plan/apply on a LocalStack sandbox
    →
  • Git & GitHub
    Object model, plumbing, branching, GitHub Actions
    →
All tutorials →
PricingAboutSign inCreate account
/
  • Introduction
  • Lessons
  • How it works
  • Simulator
  • Knowledge base
  • Interview prep
home/linux/how/dhcp

how/network

How DHCP hands out IP addresses

You join Wi-Fi, and a second later you already have an IP. Where it comes from, who picks it, and why all of it works in 4 packets.

You join the Wi-Fi at a cafe, and a couple of seconds later sites are already loading. But for them to load, your laptop needs four things:

  • its own IP address (for example 192.168.1.50)
  • a subnet mask: where "your own network" ends
  • a default-gateway: where to send packets going "outward" (see default-gateway)
  • a DNS server: who turns a name into an IP

Without them the laptop does not know who it is, where to send data, or who to ask questions. You can set all of it by hand, but the cafe will not hand you a slip with the parameters when you walk in. DHCP solves this: a protocol that hands out network settings automatically in 4 short messages.

Press ▶ and watch the laptop get its IP half a second after connecting.

step 1/5·00 · the laptop joined the network, no IP
client · eth0no ipdhcp · 192.168.1.1pool: 192.168.1.100-.200устройство в сети, ip не назначен - пора запроситьrfc 2131 · протокол поверх udp 67/68

§ steps

  1. The link is up (cable plugged in / Wi-Fi connected), but the laptop has no IP address. Without an IP you cannot reach the network, not the internet, not even the neighbor in the next room.

    To ask for settings, the laptop will send packets with a temporary src address 0.0.0.0, which means "I have no address". Then the request flies out by broadcast, so that "any DHCP server hears it".

recap

What to remember:

  • The DHCP exchange is called DORA after the first letters: Discover, Offer, Request, Acknowledge. Four packets, and all the settings are in hand
  • The first two messages go out by broadcast (to "the whole network at once", see broadcast-domain). The client has no IP of its own yet, so it has nothing to put in as a "return address"
  • The IP is handed out on a lease for a limited time (an hour to a day). Near the end of the lease the client tries to renew it, now with a directed packet, not a broadcast
  • One network can have several DHCP servers (redundancy). Then the client gets several offers and picks the first one, or by its own logic
  • If DHCP failed, on Linux/macOS the client gives itself a link-local address from 169.254.0.0/16. There will be no internet, but local neighbors will be visible

If you are curious how packets work at L2 (what broadcast is and how a packet even travels without an IP), see arp and ethernet-frame.

§ dig into the knowledge base

  • broadcast-domainbroadcast domain - who hears the "shout" on the network
  • default-gatewaydefault-gateway - where to send things "outward"
  • ipv4-addressingIPv4 addressing - what a subnet mask is
  • arpARP - the next step after getting an IP
Footer
linuxlab-
Copyright © 2026 LinuxLab. All rights reserved.
Tutorials
Pricing
About
Privacy & cookies