How does DHCP assign an IP address to a device? Explain DORA.
MediumConceptARP, DHCP & NAT
Answer
DHCP (Dynamic Host Configuration Protocol) automatically gives a device an IP address and other settings when it joins a network, so nobody has to configure each device by hand. It runs over UDP (server port 67, client port 68) and uses four messages, remembered as DORA: Discover, Offer, Request, Acknowledge.
- The client has no IP address yet, so it broadcasts, using source
0.0.0.0and destination255.255.255.255. - Besides the address, the server supplies the subnet mask, default gateway, DNS servers and a lease time; the client tries to renew the lease when half of it has passed.
- The Request is broadcast so that every server that made an offer learns which one was accepted. If the server is on another subnet, a router acting as a DHCP relay agent forwards the messages.
Example: A laptop joins the office Wi-Fi:
Laptop -> broadcast : DISCOVER "I need an address"
Server -> laptop : OFFER "you can use 192.168.1.50, lease 24 h"
Laptop -> broadcast : REQUEST "I accept 192.168.1.50 from this server"
Server -> laptop : ACK "confirmed; mask 255.255.255.0, gateway 192.168.1.1"
If no server answers, the laptop gives itself a 169.254.x.x address and cannot reach the internet.
More in ARP, DHCP & NAT
| # | Problem | Platform | Difficulty | Open | 1st1st Visit | 2nd2nd Visit | RevRevise |
|---|---|---|---|---|---|---|---|
| 1 | How does DHCP assign an IP address to a device? Explain DORA. | Concept | Medium | Read the answer to How does DHCP assign an IP address to a device? Explain DORA. | |||
| 2 | How does ARP find the MAC address for an IP address? | Concept | Medium | Read the answer to How does ARP find the MAC address for an IP address? | |||
| 3 | What is NAT, and why is it used? | Concept | Medium | Read the answer to What is NAT, and why is it used? | |||
| 4 | What is ICMP, and how do ping and traceroute work? | Concept | Medium | Read the answer to What is ICMP, and how do ping and traceroute work? |