DNS and DHCP explained for office networks

DNS turns names into IP addresses; DHCP hands out IP addresses and network settings. Almost every “the internet is down” or “can’t find the server” call in an office comes back to one of the two. This guide explains how both work on a typical Windows network, how to set them up, and how to troubleshoot them.

DNS: the network’s phone book

Computers connect to IP addresses, people use names. When you open fileserver.howitwork.local or microsoft.com, the PC asks a DNS server for the matching IP address, then connects to it.

The answer is cached for a while (the record’s TTL), so repeated lookups are fast and the DNS server isn’t asked every time.

The DNS records you will meet

  • A: name to IPv4 address (fileserver → 192.168.10.20). AAAA is the IPv6 version.
  • CNAME: an alias that points to another name (intranet → web01.howitwork.local).
  • MX: which server receives email for a domain.
  • PTR: reverse lookup, IP address to name. Useful in logs and troubleshooting.
  • SRV: “where is the service?” Active Directory publishes SRV records so PCs can find domain controllers, for example _ldap._tcp.dc._msdcs.howitwork.local.

DNS in an Active Directory network

Active Directory depends on DNS. Your domain controllers normally run the DNS service, hold the company’s internal zone (howitwork.local) and forward everything else to the internet.

  • Every domain PC must use your domain controllers as its DNS servers. If a PC uses the router or a public DNS server (such as 8.8.8.8), it can’t find the domain controllers, and you get failed sign-ins, slow logons and “can’t join the domain” errors.
  • Internet names still work, because the domain controllers’ DNS forwards those queries (to your ISP or a public resolver).
  • Set the domain controllers’ own DNS to point at each other and then themselves, never only at a public server.

DHCP: automatic network settings

When a PC or phone connects, it asks for settings and a DHCP server leases it an address. The exchange has four steps, often remembered as DORA:

  1. Discover: the client broadcasts “is there a DHCP server?”
  2. Offer: a server offers an address.
  3. Request: the client asks for that address.
  4. Acknowledge: the server confirms, with the lease time and options.

Besides the IP address and subnet mask, DHCP options give the client its default gateway (option 003, the router), DNS servers (option 006) and DNS domain name (option 015).

Scopes, leases and reservations

  • Scope: the range of addresses a DHCP server may hand out on one subnet, for example 192.168.10.100 to 192.168.10.200. Keep servers, printers and network devices outside the range or use reservations.
  • Lease: how long a client may keep its address before renewing. Eight days is the Windows default; shorter (one day or less) suits guest Wi-Fi with many short visits.
  • Reservation: always gives the same address to one device, identified by its MAC address. Good for printers and access points.

Set up DHCP on Windows Server (PowerShell)

These commands use the DhcpServer module, installed with the DHCP Server role. In an Active Directory domain, a Windows DHCP server must be authorised before it hands out addresses.

# Install the role and authorise the server in Active Directory
Install-WindowsFeature DHCP -IncludeManagementTools
Add-DhcpServerInDC -DnsName dc1.howitwork.local -IPAddress 192.168.10.10

# Create a scope for the office LAN
Add-DhcpServerv4Scope -Name "Office LAN" -StartRange 192.168.10.100 `
  -EndRange 192.168.10.200 -SubnetMask 255.255.255.0

# Gateway, DNS servers (your domain controllers) and domain name
Set-DhcpServerv4OptionValue -ScopeId 192.168.10.0 -Router 192.168.10.1 `
  -DnsServer 192.168.10.10,192.168.10.11 -DnsDomain howitwork.local

# Reserve an address for a printer
Add-DhcpServerv4Reservation -ScopeId 192.168.10.0 -IPAddress 192.168.10.50 `
  -ClientId "AA-BB-CC-DD-EE-FF" -Name "Printer-Finance"

# See who has which address
Get-DhcpServerv4Lease -ScopeId 192.168.10.0

Run only one DHCP service per subnet. If the router’s built-in DHCP is also on, clients get random settings from whichever answers first.

Troubleshooting from the client

# What did the PC actually get? (address, gateway, DNS servers, lease)
ipconfig /all

# Ask for a new lease
ipconfig /release
ipconfig /renew

# Clear the local DNS cache after a record changes
ipconfig /flushdns

# Test name resolution against a specific DNS server
nslookup fileserver.howitwork.local 192.168.10.10
Resolve-DnsName microsoft.com

Common problems and what they mean

  • Address starts with 169.254: the PC got no answer from DHCP and gave itself an automatic (APIPA) address. Check the cable or Wi-Fi, the switch port or VLAN, and that the DHCP service is running with free addresses.
  • Websites work by IP but not by name: DNS. Check the DNS servers in ipconfig /all and test with nslookup.
  • Internal servers can’t be found, the internet works: the PC is using the router or a public DNS server instead of your domain controllers.
  • “Duplicate IP address” warnings: a device was given a static address inside the DHCP range. Move it outside the range or make a reservation.
  • New devices get no address: the scope is full. Check leases, shorten the lease time on busy guest networks, or enlarge the range.

Practise for free

In a lab with a Windows Server evaluation VM, install the DNS and DHCP roles, create a scope like the one above, and join a Windows 11 VM. Then break things on purpose (stop the DHCP service, point the client at 8.8.8.8) and use the commands above to find the cause.

More IT guides · howITwork on YouTube