By the end of this lesson you will be able to
- Explain what DHCP does and what a lease is.
- Describe the steps of a DNS lookup from the browser to the answer.
- Say what the default gateway is and why every device needs one.
- Find the gateway and DNS server of your own computer on Ubuntu or Windows.
- Match a symptom, such as a site not found, to a DHCP, DNS or gateway cause.
Three quiet helpers make an ordinary web visit possible, and when any one fails the symptoms look similar: the page will not load. DHCP gives your device an address, DNS turns the name you typed into an address, and the default gateway is the door out of your home. When you can tell them apart, you can say which one is broken instead of just saying that the internet is down.
DHCP: addresses handed out automatically
Last lesson you saw that every device needs an IP address. Typing one in by hand for every phone and laptop would be tiring and easy to get wrong. Instead, your router runs a service called DHCP (Dynamic Host Configuration Protocol). A device that joins the network simply asks, and DHCP replies with an address and the other settings it needs.
Think of a cloakroom at a hall. You hand in nothing and are given a numbered ticket for the evening. When you leave, the ticket can be given to someone else. In the same way DHCP lends an address for a limited time. That loan is called a DHCP lease. Before it ends, the device quietly asks to renew it. If a device leaves and never renews, its address goes back into the pool.
A DHCP reply contains four things, all in one go: an IP address for the device, the subnet mask, the address of the default gateway and the address of a DNS server.
Read this figure as text
A sequence diagram of a laptop and a router exchanging four DHCP messages.
Two actors: a laptop and the router, which runs the DHCP service. Message 1, laptop to router: Is there a DHCP service here? I need an address. Message 2, router to laptop: Yes. I can lend you 192.168.1.20. Message 3, laptop to router: Good, I would like to use 192.168.1.20. Message 4, router to laptop: Confirmed. It is yours for 24 hours, the gateway is 192.168.1.1 and the DNS server is 192.168.1.1. The 24 hours is a made-up example of a lease length.
The default gateway: the door out
Your device knows how to deliver data to its neighbours on the same subnet. For everything else, such as a website on the other side of the world, it needs help. It sends the packet to one trusted neighbour that knows the way out. That neighbour is the default gateway. In nearly every home it is the router, with an address like 192.168.1.1.
Read this figure as text
A network diagram where a laptop talks to a printer directly and to the internet through the router.
A laptop at 192.168.1.20 and a printer at 192.168.1.30 are on the same subnet inside the home zone, and the router at 192.168.1.1 is also in the home zone. Step 1: the laptop sends a print job straight to the printer, because its address is on the same subnet. Step 2: the laptop sends a request for a website to the router, which is its default gateway, because the website is not on the subnet. Step 3: the router forwards the request out to the internet, shown as a cloud.
DNS: names into numbers
People remember names such as example.org. Packets need numbers. The Domain Name System (DNS) is the worldwide directory that turns one into the other, a bit like the contacts list on your phone: you choose Amina, and the phone dials the number. Without DNS you would have to type a number such as 198.51.100.40 for every site.
Your computer asks a DNS resolver, a server whose job is to find the answer. DHCP told your computer which resolver to use; at home it is usually your router, which passes questions on to the resolver run by your provider. If the resolver does not know, it asks other servers in turn: first one that knows the whole internet's top level, then the one responsible for .org, then the one responsible for example.org, which gives the final address.
Read this figure as text
A sequence diagram of a browser, a resolver and three DNS servers answering a lookup for example.org.
Actors: browser, resolver, root server, .org server and example.org server. Message 1, browser to resolver: What is the address of example.org? Message 2, resolver to root server: Who knows about .org? Message 3, root server to resolver: Ask the .org server. Message 4, resolver to the .org server: Who knows example.org? Message 5, .org server to resolver: Ask the example.org server. Message 6, resolver to the example.org server: What is the address of example.org? Message 7, example.org server to resolver: It is 198.51.100.40. Message 8, resolver to browser: 198.51.100.40. The browser can now send its request to that address. The address is made up for the lesson.
This looks long but takes a few thousandths of a second, and the answer is remembered. A DNS cache stores recent answers on your computer, your router and the resolver, so the second visit to a site does not need the whole chain. Answers are kept for a time chosen by the site's owner and then dropped, so that a change of address eventually spreads everywhere.
Try it: step through a lookup
Choose a made-up domain and step through the questions and answers that turn it into an IP address.
Loading lab…
Find your own gateway and DNS server
Show the gateway and DNS server
The Terminal and Command Prompt were introduced in earlier modules. Type each command exactly as shown and press Enter.
ip route show default asks the system for its default route: the gateway that handles everything outside your subnet. resolvectl status shows the DNS servers in use. Both only display information.
ip route show default
resolvectl status- Marker 1: Command: show the default route
- Marker 2: The default gateway
- Marker 3: Command: show DNS settings
- Marker 4: The DNS server in use
Read this figure as text
A simulated terminal that runs ip route show default and resolvectl status and shows made-up output.
A simulated terminal in the home folder. Marker 1 is the command ip route show default. It prints: default via 192.168.1.1 dev wlp2s0 proto dhcp metric 600. Marker 2 points at 192.168.1.1, which is the default gateway. The word dhcp shows the setting came from DHCP. Marker 3 is resolvectl status. A line then reads Current DNS Server: 192.168.1.1, which is the resolver your computer asks (marker 4). All values are made up and yours will differ.
ipconfig lists your network connections. For each one it shows the IPv4 address, the subnet mask and the Default Gateway. Adding /all also shows the DHCP Server, the lease times and the DNS Servers. Both only display information.
ipconfig /all- Marker 1: Command: show all network settings
- Marker 2: The default gateway
- Marker 3: The device that lent the address
- Marker 4: The DNS server in use
Read this figure as text
A simulated PowerShell window running ipconfig /all with made-up output.
A simulated PowerShell window. Marker 1 is the command ipconfig /all. Below the heading Wireless LAN adapter Wi-Fi, the lines show: DHCP Enabled: Yes; IPv4 Address: 192.168.1.20; Subnet Mask: 255.255.255.0; Default Gateway: 192.168.1.1 (marker 2); DHCP Server: 192.168.1.1 (marker 3); and DNS Servers: 192.168.1.1 (marker 4). The lease dates are also shown. All values are made up and yours will differ.
| Symptom | Likely helper | What it means |
|---|---|---|
| Address starts 169.254, connection limited | DHCP | No address was lent to the device |
| Can open a site by number but not by name | DNS | Names are not being turned into numbers |
| Can reach the printer and the router but nothing outside | Gateway or provider | The way out is closed or the provider's line is down |
Common mistakes
✖ Instead of: Saying “DNS is down” whenever a page will not load.
✔ Do this: Check first whether a number works and whether other devices work. DNS is only one of several causes: DHCP, the gateway and the provider line can also fail.
✖ Instead of: Setting an address by hand without knowing the network's range.
✔ Do this: Leave DHCP on (Automatic) unless you have a clear reason. A hand-typed address can clash with another device.
✖ Instead of: Thinking the gateway and the internet are the same thing.
✔ Do this: The gateway is only the nearest door out, usually the router. The internet lies beyond the provider's line.
If something goes wrong
- The command
resolvectlis not found. - Check you are on Ubuntu 24.04 and typed it exactly. As an alternative,
cat /etc/resolv.confshows a nameserver line; on Ubuntu it may show 127.0.0.53, which is a local helper that passes questions on. ipconfigshows several adapters and I cannot tell which is mine.- Look for the one named Wi-Fi (or Ethernet if you use a cable) that has an IPv4 Address and a Default Gateway. Adapters marked Media disconnected are not in use.
Key terms
- DHCP lease
- The time for which a device may keep the address that DHCP gave it.
- DNS resolver
- The server that looks up a name for you and returns its IP address.
- DNS cache
- A short-term memory of recent DNS answers, which saves asking the same question again.
Practise it for real
Reading is not the same as being able to do it. Complete these on your own computer, then tick only what you have actually done. These ticks are your own honest record: nothing checks them for you.
Read your own network settings
On your real computer, use the command for your system in the lesson to find your default gateway and your DNS server. Write down both, plus your IPv4 address. Then compare: is the gateway in the same subnet as your address (do the first three numbers match)? Is the gateway the same as the DNS server? Do not share these numbers online.
Challenge: DHCP, DNS or gateway?
For each case, decide whether DHCP, DNS or the gateway is the most likely cause and explain why in one sentence. (a) A laptop shows 169.254.12.7 and no sites load. (b) A browser says the site cannot be found, but a chat app on the same computer still works. (c) Everything on the home network works, including the printer, but no website opens on any device and the router's internet light is off.
Knowledge check
6 questions. You need 80% to pass. Mistakes here are part of learning, and you can retry as often as you like.
Summary
- DHCP lends each device an address, mask, gateway and DNS server for a limited time called a lease.
- The default gateway is the door out of your subnet, normally your router.
- DNS turns names into addresses through a resolver that asks a chain of servers and caches answers.
- Different symptoms point to different helpers: 169.254 means DHCP, names failing but numbers working means DNS.
Checklist: can you do these?
Marking a lesson as read does not prove you can do it. Skills count as demonstrated when you pass the quiz (not yet) and complete the practical tasks (not yet).
Related lessons
References and further reading
Official sources for details that can change between versions.
- What is DNS? (MDN Web Docs)
- ipconfig command reference (Microsoft Learn)
- Networking, web, email and chat (Ubuntu Desktop Guide) (Ubuntu)