task 1.2 · chapter 1 of 3: your computer · 25 min
Get an address
objective
Find the four things the laptop borrowed from DHCP (its address and mask, its gateway, its DNS server, and how long it can keep them), watch it ask again message by message, then make r1 keep 192.168.1.50 for the laptop.
Your answersin the lab app: Your answers, under the guide. Check task saves them
| Lessons used | 4.1 DHCP, step by step, 3.2 CIDR |
|---|---|
| Log in | click laptop on the Topology tab (and r1 for the router) |
| Your answers | under the guide, in the lab app: the follow-along part. The challenge is a change on r1 |
new to this? step by stepbeginner
- Click laptop on the Topology tab. In the laptop tab:
ip addr show eth1,ip routeandcat /etc/resolv.conf. - Ask again by hand:
pkill udhcpc, thenudhcpc -i eth1 -q. Write the four answers in Your answers, under the guide. - Click r1 on the Topology tab. In the r1 tab:
show ip dhcp binding. - Challenge: on r1, a pool that keeps
192.168.1.50for the laptop’s MAC address. Then ask again on the laptop. - Check task 1.2, under the guide.
more in meet the lab
What the laptop borrowed
Four things, on loan
In lesson 4.1 you watched a laptop plug in with no address and come out with four things, after four messages (Discover, Offer, Request, Ack):
- an IP address and its subnet mask;
- a default gateway: the router, the way out to other networks;
- a DNS server: the computer that turns names into addresses (task 3.2 is all about it);
- a lease: how long it can keep them before it has to ask again.
The lab’s laptop did exactly that when the lab started. Task 1.1 found the first one with ip addr. This task
finds the other three, then makes it ask again so you can watch.
in one sentence DHCP lends a host an address and mask, a gateway and a DNS server, for the length of a lease.
Where a computer keeps them
Linux keeps each one in a different place, and each has its own way to look:
| What | Where to look | What you’ll see |
|---|---|---|
| address and mask | ip addr show eth1 | inet 192.168.1.100/24: the mask is the /24 |
| default gateway | ip route | a line starting default via: anything that isn’t for a network I know, send it here |
| DNS server | cat /etc/resolv.conf | a line starting nameserver |
| lease | the DHCP client’s messages | lease time 3600: in seconds |
cat prints a file (it’s short for concatenate, an old word for joining files together). /etc/resolv.conf
is the file where Linux writes down which DNS server to ask. The DHCP client fills it in.
in one sentence The address is in ip addr, the gateway in ip route, the DNS server in /etc/resolv.conf.
The client and the server
Two programs do DHCP. On the laptop, a DHCP client asks; here it’s called udhcpc (micro DHCP client:
it’s a small one). On r1, a DHCP server answers, from a pool: a list of addresses it’s allowed to
hand out, plus the gateway and DNS server to go with them. r1 writes down who has which address in its
bindings: a binding ties an address to one host’s MAC address.
in one sentence The client on the laptop asks; the server on r1 answers from its pool and writes down the binding.
Keeping a desk free for one student
Remember the new student in lesson 4.1, asking where to sit? Most students take any free desk. But the teacher might keep desk 10 for one student, every day: whoever else comes in first, that desk is theirs.
DHCP can do that too. It’s called a reservation: the server keeps one address for one MAC address, and gives it to nobody else. People reserve addresses for things that others need to find, like printers, so the address never changes.
in one sentence A reservation keeps one address for one MAC address, so that host always gets the same one.
DORA, as udhcpc tells it
When you run the laptop’s DHCP client by hand, it says what it’s doing, one line per step:
laptop:~# udhcpc -i eth1 -q
udhcpc: started, v1.37.0
udhcpc: broadcasting discover
udhcpc: broadcasting select for 192.168.1.100, server 192.168.1.1
udhcpc: lease of 192.168.1.100 obtained from 192.168.1.1, lease time 3600
| Line | Which DHCP message | From lesson 4.1 |
|---|---|---|
broadcasting discover | the laptop’s Discover, shouted to everyone | anyone there? |
| (no line) | r1’s Offer arrives. udhcpc doesn’t print it, but the next line shows what was in it | 192.168.1.100 is free |
broadcasting select for 192.168.1.100, server 192.168.1.1 | the Request. udhcpc calls it select: it picks this offer, from this server | yes please, that one |
lease of 192.168.1.100 obtained ... lease time 3600 | r1’s Ack: it’s the laptop’s now, for 3600 seconds | it’s yours |
Look at the words broadcasting: the Discover and the Request are both shouts to everyone, as in the lesson.
-i eth1 means on the eth1 card, and -q means quit once you have an address (otherwise it keeps
running, to ask again before the lease runs out).
On r1, the same conversation, from the server’s side:
r1#show ip dhcp binding
Bindings from all pools not associated with VRF:
IP address Client-ID/ Lease expiration Type State Interface
Hardware address/
User name
192.168.1.100 01aa.aaaa.1111.11 Nov 10 2026 03:20 PM Automatic Active GigabitEthernet1
| Column | What it says |
|---|---|
IP address | the address r1 lent |
Client-ID | who to: 01 means Ethernet, and the rest, aa.aaaa.1111.11, is the laptop’s MAC address in different groups |
Lease expiration | when the loan runs out, unless the laptop asks again first (the date and time are the lab’s clock) |
Type | Automatic: the next free address from the pool. A reservation says Manual |
Interface | the router port the request came in on: GigabitEthernet1, the home network |
Routers and switches write MAC addresses in three groups of four, with dots: aaaa.aa11.1111 is the same
address as aa:aa:aa:11:11:11.
Read the loan, then ask again
Log in to the laptop: click laptop on the Topology tab. In the laptop tab, look at its address, its routes and its DNS settings:
run in the laptop tabip addr show eth1 ip route cat /etc/resolv.confip routeprints two lines:default via 192.168.1.1 dev eth1 192.168.1.0/24 dev eth1 proto kernel scope link src 192.168.1.100The first is the default gateway:
192.168.1.1, which is r1. The second says the laptop’s own network,192.168.1.0/24, is right there oneth1: no gateway needed for it. That’s the rule from lesson 3.2, written down by the computer./etc/resolv.confsaysnameserver 192.168.2.53, the DNS server, andsearch lab(task 3.2 explains that one).Still in the laptop tab, stop the DHCP client that’s running in the background, and run it again by hand so you can watch:
run in the laptop tabpkill udhcpc udhcpc -i eth1 -q(
pkillstops a running program by its name.) You’ll see the four lines from the show step, ending with the address, the server and the lease time.Now look from r1’s side: click r1 on the Topology tab. In the r1 tab:
run in the r1 tabshow ip dhcp binding show ip dhcp poolThe prompt on r1 is
r1#.show ip dhcp poolcounts the pool’s addresses: 254 in all, 99 kept back (excluded, for things with fixed addresses, like the printer), 1 leased.Fill in Your answers, under the guide:
editYour answersunder the guideThe DHCP server's address: 192.168.1.1 The laptop's default gateway: 192.168.1.1 The laptop's DNS server: 192.168.2.53 The lease time, in seconds: 3600The DHCP server and the gateway are the same box here, r1, as in most homes. They don’t have to be.
in one sentence udhcpc shows DORA from the laptop’s side; show ip dhcp binding shows the same loan from the router’s.
Keep 192.168.1.50 for the laptop
Make r1 give the laptop 192.168.1.50 every time, then have the laptop ask again so it gets it. The laptop
must still get its gateway and its DNS server.
To change a router you go into configuration mode: configure terminal (the prompt becomes
r1(config)#), type the settings, then end. A pool is made with ip dhcp pool NAME, which opens that pool’s
settings (r1(dhcp-config)#). A reservation is a pool of its own, with two settings that make it one:
host 192.168.1.50 255.255.255.0
client-identifier 01aa.aaaa.1111.11
host is the address and mask to keep. client-identifier says who it’s kept for: the Client-ID you saw
in show ip dhcp binding, 01 for Ethernet followed by the laptop’s MAC address. A DHCP client sends its
Client-ID in every request, and the laptop’s udhcpc does, so that’s what the router matches on. (There’s
also a hardware-address setting, for the MAC address alone, but it only matches clients that send no
Client-ID.)
hint
The commands go on r1, in the r1 tab: configure terminal, then ip dhcp pool LAPTOP (any name will
do).
hint
Some routers copy the HOME pool’s gateway and DNS server into a reservation, and some don’t. Put them in the
reservation itself, so it works either way: show running-config shows HOME’s settings to copy.
hint
To ask again on the laptop, go back to the laptop tab and do what you did in the follow-along: pkill udhcpc,
then udhcpc -i eth1 -q.
show the solution
In the r1 tab:
r1#configure terminal
r1(config)#ip dhcp pool LAPTOP
r1(dhcp-config)# host 192.168.1.50 255.255.255.0
r1(dhcp-config)# client-identifier 01aa.aaaa.1111.11
r1(dhcp-config)# default-router 192.168.1.1
r1(dhcp-config)# dns-server 192.168.2.53
r1(dhcp-config)# domain-name lab
r1(dhcp-config)#end
r1#
In the laptop tab:
laptop:~# pkill udhcpc
laptop:~# udhcpc -i eth1 -q
udhcpc: started, v1.37.0
udhcpc: broadcasting discover
udhcpc: broadcasting select for 192.168.1.50, server 192.168.1.1
udhcpc: lease of 192.168.1.50 obtained from 192.168.1.1, lease time 86400
The lease is 86400 seconds, a whole day, because the LAPTOP pool doesn’t set one and a day is the default.
show ip dhcp binding on r1 now says 192.168.1.50 ... Manual.
Setting default-router and dns-server in the reservation makes sure the laptop gets them. Without them it
would still get 192.168.1.50, but on a router that doesn’t copy them from HOME, ip route would have no
default via line and /etc/resolv.conf would be empty: it could reach its own network and nothing else.
From now on the laptop is 192.168.1.50. The rest of the guide shows that address. If you see .100,
you skipped this challenge or clicked Reset network; Solve it for me, next to Check task, puts the reservation back.
5 check: run it, then prove it
Check task 1.2 under the guide, in the lab app
when it's right, you'll see
╭─ task 1.2 · get an address
│ ✓ the DHCP server (follow along): 192.168.1.1
│ ✓ the default gateway (follow along): 192.168.1.1
│ ✓ the DNS server (follow along): 192.168.2.53
│ ✓ the lease time, in seconds (follow along): 3600
│ ✓ r1 has a pool that keeps 192.168.1.50 for the laptop's MAC address (challenge): LAPTOP
│ ✓ the laptop has 192.168.1.50/24 (challenge): it has 192.168.1.50/24
│ ✓ and still a gateway and a DNS server (challenge): gateway 192.168.1.1, DNS 192.168.2.53
╰─ 7/7 checks passed verified