Run a DHCP scope with a reservation and options, and read the lease

short · 45 min · Objective 2.2

Task

Make win-srv the DHCP server for the lab network, with a scope, an exclusion range, a reservation for one machine and the router and DNS options, then have a client obtain an address and prove it received exactly what the scope says: the reserved address, the gateway and the DNS server.

Steps

  1. On win-srv, add the DHCP Server role and create a scope for 192.168.56.100 to 192.168.56.199, excluding 192.168.56.100 to 192.168.56.109, with option 3 (router) set to 192.168.56.1 and option 6 (DNS) set to 192.168.56.20. Save Get-DhcpServerv4Scope and Get-DhcpServerv4OptionValue -ScopeId 192.168.56.0 to lab/dhcp/scope.txt.
  2. Find the client VM's MAC address and create a reservation for it at 192.168.56.150. Save Get-DhcpServerv4Reservation -ScopeId 192.168.56.0 to lab/dhcp/reservation.txt.
  3. On the client, release and renew its DHCP lease (nmcli con down and up on Rocky; networkctl renew <if> on Ubuntu Server, which has no dhclient or nmcli by default). Save ip -br addr, ip route and the DNS server the client was given to lab/dhcp/client.txt -- on Ubuntu that is resolvectl dns, because /etc/resolv.conf there names only the local stub, 127.0.0.53.
  4. On win-srv, save Get-DhcpServerv4Lease -ScopeId 192.168.56.0 to lab/dhcp/leases.txt.
  5. Record in lab/dhcp/notes.txt what a client does if no DHCP server answers, and the address range it would give itself.

Verify

These checks run in a POSIX shell: Terminal on macOS or Linux, and on Windows Git Bash (it comes with Git for Windows) or WSL. A stock Windows PowerShell or Command Prompt has no awk or grep, so there the first line fails.

grep -c '192.168.56.100' lab/dhcp/scope.txt
grep -c '192.168.56.150' lab/dhcp/reservation.txt lab/dhcp/client.txt lab/dhcp/leases.txt
grep -c 'default via 192.168.56.1' lab/dhcp/client.txt
grep -c '192.168.56.20' lab/dhcp/client.txt
grep -c '169.254' lab/dhcp/notes.txt

The reserved address 192.168.56.150 appears in the reservation, on the client and in the lease table; the client's default route is the router option; and its DNS server is win-srv. Your notes should name the 169.254 range, the APIPA address a client gives itself when DHCP fails.

Notes

If the client received an address from the hypervisor's range instead, its own DHCP service is still answering, which is the rogue DHCP problem in miniature: two servers, and the client takes whichever replies first.

This is an independent study companion for CompTIA Server+ SK0-005 and is not produced by or endorsed by CompTIA.