How Your Laptop Joins a Network
Your laptop joins Wi-Fi with no IP address, no gateway, and no DNS server, and two seconds later it's online. Here's every step: Wi-Fi association, DHCP's four messages (DORA), the subnet mask's "local or not?" decision, ARP, and how switches learn. Plus how attackers abuse all of it (rogue DHCP, ARP spoofing, MAC flooding), and why TLS still protects you on café Wi-Fi.
Chapters
- 0:00 Intro
- 0:41 Five devices in one box
- 1:19 MAC addresses
- 2:03 Getting on the Wi-Fi
- 2:46 DHCP
- 3:53 What DHCP actually gave you
- 4:41 ARP
- 5:38 How a switch learns
- 6:21 The first packet, finally
- 6:56 What can go wrong
- 8:09 And on IPv6?
- 8:35 Try it yourself
- 9:17 Interview corner
- 10:30 Recap and next stop
Transcript
You open your laptop in a café, click a network name, and about two seconds later you're online. In those two seconds, your laptop asked a stranger for an identity, found out where the exit is, and announced itself to every device in the room. None of it needed you to type an address, or a single setting. That's also a favourite interview question: what happens when you join a Wi-Fi network? Today, we zoom into the very first hop of every journey: your local network.
This is Just Known. From unknown, to known. Episode three: how your laptop joins a network. Let's meet the cast. At home, everything lives in one plastic box we call the router.
But that box is really five devices in one. A Wi-Fi access point, which turns radio into network traffic. A switch, which connects the devices on your local network. A router, which forwards traffic between your network and the internet. A DHCP server, which hands out addresses.
And a firewall, which also does the NAT we met in episode one. In an office, these are often separate boxes. But the jobs are the same, and today we'll watch each one do its part. First, names. Every network card has a hardware address, called a MAC address: forty-eight bits, usually written as six pairs of hex digits.
The first half traditionally identifies the manufacturer, and the second half identifies the device. Remember from the last episode: MAC addresses only matter on your local network. They're the link layer's addresses, and every router replaces them on the next hop. So a MAC address never travels across the internet. One modern twist: phones and laptops now often randomize their MAC address for each network they join.
Same device, a different name at every café. That makes it much harder to track you from place to place. Before any of that, the laptop has to get onto the Wi-Fi itself. Access points constantly broadcast their network name. Your laptop picks one, and asks to connect.
On a protected network, the two then run a short handshake. It proves you know the password, without ever sending the password over the air, and it gives both sides fresh encryption keys for this session. From now on, the radio link between your laptop and the access point is encrypted. So now your laptop is connected. But it still has no IP address.
It doesn't know its own address, the router's address, or where to send DNS questions. It's on the network, but it can't talk to anyone yet. The fix is a protocol called DHCP, and it's a conversation of four messages. First, discover. The laptop has no address, so it sends from zero point zero point zero point zero to the broadcast address, which means everyone on this network.
The message just says: is there a DHCP server out there? Second, offer. The server replies: you can be 192.168.1.23, here's how long you can keep it, and here's some advice. Third, request. The laptop answers: yes, I'll take that one.
It broadcasts this too, so that any other DHCP server that made an offer knows it wasn't chosen. And fourth, acknowledge. The server confirms: it's yours. Discover, offer, request, acknowledge. People remember it as DORA.
The address is only a lease, often a day at home. About halfway through, the laptop quietly asks to renew it, and usually just keeps the same one. That "advice" matters as much as the address itself. Along with your IP, DHCP hands over three more things. A subnet mask, which describes how big the local network is.
A default gateway: the router's address, the exit to everywhere else. And a DNS server, which is where the question from episode one, where is example.com, gets sent. The mask lets your laptop answer one question before every single packet: is this destination local, or not? If it's on the same network, like the phone sitting at the next table, the laptop delivers it directly. If it's anywhere else, like example.com, the packet goes to the gateway.
We'll work out exactly how a mask answers that question in episode four. The laptop now knows the gateway's IP address. But to put a frame on the wire, it needs the gateway's MAC address. That's the job of ARP, the address resolution protocol. The laptop broadcasts a question to everyone: who has 192.168.1.1?
Tell 192.168.1.23. Every device hears it, and everyone except the router ignores it. The router replies directly to the laptop: 192.168.1.1 is at this MAC address. The laptop stores that answer in its ARP cache, so it doesn't have to ask before every packet. Entries expire after a while, and get refreshed when they're needed.
Devices can also announce themselves without being asked, with what's called a gratuitous ARP. That's useful when a device changes its address, and, as we'll see, it's also an open door. Meanwhile, inside that box, the switch is learning. Every time a frame arrives, the switch notes which port that source MAC address came from, in its MAC address table. When a frame comes in for a destination it hasn't seen yet, the switch simply floods it out of every port, and lets the right device pick it up.
But once it knows where an address lives, it sends frames only to that one port. Broadcasts, like the ARP question and the DHCP discover, always go to every port. That's what makes them work. Old network hubs repeated everything to everyone, all the time. A switch learns, so your traffic mostly reaches only the device it's meant for.
Now we can finally build the very first packet from episode one: the DNS question. Its source IP address came from DHCP. Its destination, the DNS server, also came from DHCP. Its source MAC address is your own network card. And its destination MAC, the router's, came from ARP.
Every field is now filled in. The packet leaves your laptop, crosses the Wi-Fi to the router, and starts the journey we followed in episode one. Every request you've ever made started with these exact steps. Now, the way an attacker sees this. Every protocol we just met was designed for a friendly room.
None of them checks who's talking. So if someone on the network runs their own DHCP server, and answers faster than the real one, your laptop happily accepts their advice: the attacker becomes your gateway and your DNS server. That's a rogue DHCP server. ARP is even easier. An attacker can send gratuitous ARPs claiming that the router's IP address belongs to their MAC.
Your laptop updates its cache, and starts sending everything through the attacker's machine. That's ARP spoofing, a classic man in the middle. And a flood of fake MAC addresses can overflow a switch's table, until it falls back to flooding traffic out of every port, like an old hub. Office networks fight back with switch features like DHCP snooping, dynamic ARP inspection, port security, and 802.1X logins. On networks you don't control, like that café, your best friend is TLS.
Even if someone sits in the middle, they can't read or change what's inside. That padlock really matters. Quick note on IPv6, the newer version of IP. It replaces ARP with a similar protocol called neighbor discovery. And instead of always asking a server for an address, a device can build its own: the router advertises the network's prefix, and the device fills in the rest, often with a random part for privacy.
DHCP still exists for IPv6, but many networks don't need it. You can see all of this on your own machine. On Windows, run ipconfig, slash all. You'll see your IP address, subnet mask, default gateway, DHCP server, DNS servers, and even when your lease expires. On Mac or Linux, the ip commands show the same things.
Then run arp, dash a. There's your ARP cache, with your router's IP address and its MAC address right next to it. And for the full story, open Wireshark, filter for DHCP or ARP, and reconnect to your Wi-Fi. You'll watch the four DHCP messages fly by in real time. The commands are in the description.
Interview corner. Walk me through what happens when a laptop joins a network, until it can reach the internet. Pause here, and try it.
Here's a strong answer. First, the laptop associates with the access point, and on a protected network runs a handshake to set up encryption. Second, it gets an address with DHCP: discover, offer, request, acknowledge. Third, that gives it an IP address, a subnet mask, a default gateway, and a DNS server. Fourth, it uses ARP to find the gateway's MAC address.
And fifth, for each packet, it checks: local destinations get delivered directly, and everything else goes to the gateway. For bonus points, mention what can go wrong: rogue DHCP servers and ARP spoofing, and why TLS still protects you on an untrusted network. Bonus question: why does your laptop ask for the router's MAC address, and not example.com's? Because MAC addresses only work on your local network. Anything beyond it goes to the gateway, and the router takes it from there.
Let's recap. When your laptop joins a network, DHCP gives it an identity in four messages: discover, offer, request, acknowledge. ARP turns the router's IP address into a MAC address, so frames can actually be delivered. And for every packet, the subnet mask decides: deliver it directly, or hand it to the gateway. Next stop: that subnet mask, and the addresses themselves.
What does slash twenty-four really mean, why are some addresses private, and how does NAT let a whole house share one public address? That's episode four. This is Just Known. From unknown, to known.
Note: addresses on screen are from reserved documentation ranges (RFC 5737 IPv4, RFC 3849 IPv6, RFC 7042 MACs).
Narration voice generated with ElevenLabs.
