The moment you connect to Wi-Fi, your phone gets an IP. Nobody types anything. So who gives it?
DHCP
It's the router in the box at home, and it does it with a protocol called DHCP (Dynamic Host Configuration Protocol). As soon as a device connects, the router gives it an IP to use automatically, along with settings like which router to go through to reach the internet (the default gateway) and which DNS server to ask. The same thing happens for every device that joins.
DORA, step by step
Imagine you're connecting your phone to a Wi-Fi network:
- D – Discover. The phone asks: "I'm a new device and I don't have an IP. Does anyone have one?" It doesn't know who runs DHCP, so it sends this to every device on the network at once, a broadcast. The others ignore it; only the router running DHCP replies.
- O – Offer. The router: "This IP is free. Do you want it?"
- R – Request. The phone: "OK, I'll take that IP."
- A – Acknowledge. The router: "Done, it's yours."
- Discover: the phone broadcasts "Does anyone have an IP for me?"
- Offer: the router offers a free IP.
- Request: the phone asks for that IP.
- Acknowledge: the router confirms it.
This is also why your IP can change when you reconnect (lesson 4): each time, the router offers whichever IP is free.
For hackers: because the phone trusts whoever answers its broadcast, an attacker on the same network can run a rogue DHCP server and hand out their own machine as the gateway, putting themselves in the middle of the victim's traffic. That's one reason networks protect against unknown DHCP servers.
Key takeaways
- DHCP lets the router give devices an IP automatically.
- It also hands out the default gateway and DNS server.
- DORA = Discover, Offer, Request, Acknowledge.
- Discover is a broadcast, because the device doesn't know who runs DHCP yet.
Quick quiz
Pick an answer to check yourself. Answer both to mark this lesson done.
1. What is the correct order of the DORA process?
- A) Discover → Offer → Request → Acknowledge
- B) Offer → Discover → Acknowledge → Request
- C) Request → Offer → Discover → Acknowledge
- D) Discover → Request → Offer → Acknowledge
Show answer
Answer: A. The phone asks for an IP (Discover), the router offers one (Offer), the phone asks for it (Request), and the router confirms (Acknowledge).
2. Who does the phone send the Discover message to?
- A) Only the router
- B) Every device on the network (broadcast)
- C) The DNS server
- D) Facebook's server
Show answer
Answer: B. The phone has no IP and doesn't know who runs DHCP, so it broadcasts to everyone. Only the router running DHCP replies.
Module 2 test
Five questions on lessons 6 to 10.
1. If an IP is the address of a block of flats, what is a port?
- A) The building's name
- B) The door of one flat inside
- C) The road to the building
- D) The postman
Show answer
Answer: B. The IP gets data to the right device; the port gets it to the right app or service inside.
2. You need to be sure an email arrived. Which is better?
- A) UDP
- B) TCP
- C) ARP
- D) DHCP
Show answer
Answer: B. TCP checks that data arrived and resends it if not. UDP doesn't check.
3. In the 3-way handshake, what does the server send back after the client's SYN?
- A) SYN
- B) ACK
- C) SYN-ACK
- D) RST
Show answer
Answer: C. SYN → SYN-ACK → ACK. The server says "heard you" (ACK) and "I want to connect too" (SYN) together.
4. You type edwhere.com in the browser. Who is asked for its IP first?
- A) A DNS server
- B) A DHCP server
- C) The switch
- D) Wireshark
Show answer
Answer: A. DNS servers store domain names and their IPs. The browser gets the IP there, then goes to the site.
5. In DHCP's DORA process, what does "O" stand for?
- A) Open
- B) Offer
- C) Order
- D) Output
Show answer
Answer: B. Discover, Offer, Request, Acknowledge. In the Offer, the router offers a free IP.
Frequently asked questions
What does DHCP do?
DHCP automatically gives a device an IP address when it joins a network, along with the default gateway and DNS server settings.
What is DORA in DHCP?
The four DHCP messages: Discover, Offer, Request and Acknowledge.
Why does my IP address change?
Each time you connect, the DHCP server offers whichever IP is free, so you can get a different one.