DNS & DHCP From Scratch — The Services Keeping Your Lab Alive

Active Directory stood up DNS for us automatically when we promoted the domain controller in Episode 1. That was convenient — but it also meant we got DNS without really understanding it. This episode fixes that.

This is Episode 4 of the TrevTech homelab series. We’re going deeper on DNS and DHCP: what they actually do, how they’re configured on trevtech.lab, what you need to manage day-to-day, and where things go wrong.

Why DNS and DHCP Matter

DNS is the phone book of your network. When a machine needs to find DC01.trevtech.lab, it asks DNS. When a user opens a browser and types a URL, DNS translates that name to an IP. Without it, nothing works — not domain joins, not logon scripts, not drive mappings, not the internet.

DHCP is the service that hands out IP addresses automatically. Without it, every machine on your network needs a manually configured, static IP. That’s fine for 3 servers. It does not scale to 50 workstations.

Together, DNS and DHCP are the invisible plumbing that makes a network actually function. Sysadmins who understand them well can troubleshoot almost any connectivity issue. Those who don’t spend a lot of time staring at ping output and wondering why nothing works.


The Lab Context

DetailValue
Domaintrevtech.lab
Domain ControllerDC01 — 192.168.10.10
DNS serverDC01 (integrated with AD)
DHCP serverDC01 (added this episode)
DHCP scope192.168.10.50 – 192.168.10.200
Subnet192.168.10.0/24
Router/Gateway192.168.10.1
Client VMs2 x Windows 11, domain-joined

DC01 is doing three jobs: Domain Controller, DNS server, and DHCP server. In a production environment you’d split these roles across multiple servers for redundancy. In the lab, one box doing everything is fine — and it means you see how all three interact.


DNS — How It Works on trevtech.lab

When we installed AD DS in Episode 1, the wizard asked if we wanted to install DNS too. We said yes. That created:

  • A Forward Lookup Zone for trevtech.lab — translates hostnames to IPs
  • A Reverse Lookup Zone for 192.168.10.x — translates IPs back to hostnames
  • A records for DC01 (automatically) and any other records the domain needed
  • SRV records — these are the critical ones that domain-joined machines use to find the domain controller

The DNS Manager (available in Server Manager → Tools) is where you manage all of this. For the lab, the auto-generated records are enough to get started.

Key PowerShell commands for DNS:

# Add a DNS A record
Add-DnsServerResourceRecordA `
  -ZoneName "trevtech.lab" `
  -Name "fileserver" `
  -IPv4Address "192.168.10.20"

# List all A records in the zone
Get-DnsServerResourceRecord -ZoneName "trevtech.lab" -RRType "A"

# Test name resolution from any machine
nslookup DC01.trevtech.lab
nslookup 192.168.10.10

The nslookup command is your primary DNS testing tool. If a machine can resolve names and reverse-resolve IPs, DNS is healthy.


DHCP — Setting Up the Scope

DHCP wasn’t installed automatically — we need to add it. Here’s the process:

  1. Install the DHCP Server role (Server Manager → Add Roles → DHCP Server)
  2. Post-install: authorize the DHCP server in Active Directory (critical — unauthorized DHCP servers are a security issue)
  3. Create a scope: the range of IPs DHCP is allowed to hand out
  4. Add scope options: tell clients the gateway, DNS server, and domain name
  5. Activate the scope
# Install DHCP role
Install-WindowsFeature -Name DHCP -IncludeManagementTools

# Authorize the DHCP server in AD
Add-DhcpServerInDC -DnsName "DC01.trevtech.lab" -IPAddress 192.168.10.10

# Create a DHCP scope
Add-DhcpServerv4Scope `
  -Name "trevtech.lab Scope" `
  -StartRange 192.168.10.50 `
  -EndRange 192.168.10.200 `
  -SubnetMask 255.255.255.0 `
  -State Active

# Set scope options (gateway + DNS)
Set-DhcpServerv4OptionValue `
  -ScopeId 192.168.10.0 `
  -Router 192.168.10.1 `
  -DnsServer 192.168.10.10 `
  -DnsDomain "trevtech.lab"

Once this is running, any machine that connects to the 192.168.10.0/24 network will get an IP between .50 and .200, along with the gateway and DNS server automatically.

DHCP Reservations

For servers and printers, you usually want a consistent IP — but you still want DHCP to manage it. That’s what reservations are for: the DHCP server always gives a specific MAC address the same IP.

# Add a DHCP reservation (always give this MAC the same IP)
Add-DhcpServerv4Reservation `
  -ScopeId 192.168.10.0 `
  -IPAddress 192.168.10.25 `
  -ClientId "00-50-56-AA-BB-CC" `
  -Description "Print Server"

What I’m Running in the Lab

  • DHCP scope: .50 to .200 — 151 addresses, more than enough for the lab
  • Exclusions: .1 to .49 reserved for static devices (DC01 at .10, router at .1, future servers in between)
  • DNS records added manually: fileserver.trevtech.lab pointing to .20 (where the file server will live in Episode 5)
  • Both Windows 11 clients now pull addresses via DHCP — confirmed with ipconfig /all

The Gotchas

Unauthorized DHCP is a serious problem. If you spin up a DHCP server and don’t authorize it in Active Directory, Windows clients will still get addresses from it — which might conflict with your existing DHCP server. Always authorize before activating.

Scope conflicts. If you’re running another DHCP server anywhere on the segment (like your home router), you’ll get address conflicts. Either disable DHCP on the router or make sure the scopes don’t overlap. I learned this one the hard way when my home router kept handing out .100 to my lab VMs.

DNS SRV records breaking. If you ever see domain-joined machines failing to find the domain controller, check your SRV records in DNS Manager. The _msdcs.trevtech.lab zone holds the records that clients use to locate DCs. These should be auto-registered, but they can get stale or deleted if DNS has issues.

DHCP lease time. The default lease time is 8 days. In a homelab where VMs come and go, that’s fine. In a dense environment with lots of short-lived devices, you might want to reduce it. Shorter lease times mean IPs get recycled faster.


Is It Worth Understanding?

Yes — and honestly, this is one of those topics where a few hours in a homelab saves you hours of frustration in the job.

DNS and DHCP problems are some of the most common issues that end users bring to sysadmins, and they’re often straightforward to diagnose once you know what to look at. nslookup, ipconfig /all, ping, and the DHCP lease table — those four things will solve 80% of the connectivity tickets you’ll ever see.


What’s Next

Episode 5 is the final video in the homelab series: File Server & Permissions. We’re setting up a shared folder structure on trevtech.lab, configuring NTFS permissions, and making sure the right people can access the right things — and nobody else can.

Watch it on TrevTech-IT on YouTube. Drop questions in the comments — especially if you’re running into DNS issues in your own lab.

— Trev | I broke it. Fixed it.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top