SkarpSkarp

Chapter 19 of 29

DHCP and DNS: Dynamic Addressing and Name Resolution

Automate IP assignments with DHCP and translate hostnames to IPs with DNS so clients can join the network and reach services without manual configuration.

27 min readen

Big Picture: Why DHCP and DNS Matter

Invisible Helpers

Two quiet services make networks feel plug-and-play: DHCP for automatic IP configuration and DNS for translating names like `www.example.com` into IP addresses.

DHCP: The Definition

DHCP is formally defined as: "The Dynamic Host Configuration Protocol (DHCP) automatically assigns IP configuration parameters such as IP address, subnet mask, default gateway, and DNS servers to clients."

DNS: The Definition

DNS is formally defined as: "The Domain Name System (DNS) is a distributed database that maps human-readable hostnames to IP addresses and other resource records."

Why CCNA Cares

For CCNA, you must understand concepts, configure basic DHCP on Cisco routers, interpret `show` outputs, and troubleshoot client issues caused by bad DHCP or DNS settings.

Link to Earlier Topics

DHCP usually tells hosts which default gateway and DNS servers to use. That gateway often runs NAT, letting private hosts reach public names resolved by DNS.

How DHCP Works: DORA and Key Options

DORA Overview

DHCP uses the DORA sequence: Discover, Offer, Request, Acknowledge. This is how a client with no IP finds a server and gets its configuration.

Discover and Offer

Client sends a broadcast `DHCPDISCOVER` from 0.0.0.0. DHCP servers reply with `DHCPOFFER` messages proposing an IP and other settings.

Request and Acknowledge

The client sends `DHCPREQUEST` to choose an offer. The server finalizes with `DHCPACK`, confirming the lease and options like mask, gateway, and DNS.

Key DHCP Options

Important options: IP address, subnet mask, default gateway, DNS servers, and lease time. These tell the host how to reach local and remote networks.

Lease Renewal

Leases expire. Before that, the client unicasts a `DHCPREQUEST` to renew. If renewal fails, it tries broadcast; if that fails, it must stop using the IP.

Visualizing DHCP on a Small LAN

The Small Office

Picture a LAN: PCs and a Cisco router R1 on a switch. R1’s LAN interface is 192.168.10.1/24, and it also connects to the internet running NAT.

PC1 Gets an Address

PC1 boots and broadcasts `DHCPDISCOVER`. R1 hears it and replies with `DHCPOFFER` (IP, mask, gateway, DNS, lease). PC1 sends `DHCPREQUEST`, R1 answers `DHCPACK`.

Resulting Config

PC1 ends up with IP 192.168.10.11, mask 255.255.255.0, default gateway 192.168.10.1, and DNS 8.8.8.8, all learned from DHCP without manual input.

Reaching the Internet

PC1 queries DNS at 8.8.8.8 for `www.example.com`. It then sends traffic to that IP via its default gateway at 192.168.10.1, where NAT translates private to public.

Key Takeaway

DHCP provides IP, mask, gateway, and DNS. DNS resolves names. The default gateway and NAT then move traffic between the private LAN and the public internet.

Cisco Router as a DHCP Server: Core Configuration

Step 1: Exclude Addresses

Reserve static IPs first. Example: `ip dhcp excluded-address 192.168.10.1 192.168.10.10` prevents DHCP from handing out .1–.10.

Step 2: Create the Pool

Use `ip dhcp pool LAN10`, then `network 192.168.10.0 255.255.255.0`, `default-router 192.168.10.1`, and `dns-server 8.8.8.8` to define client settings.

Lease Configuration

Set lease time with `lease DAYS HOURS MINUTES`, e.g. `lease 1 12 0` for 1 day 12 hours. If omitted, a default lease applies.

Step 3: Interface Setup

Ensure the LAN interface has an IP in the same subnet and is `no shutdown`. DHCP only serves on up/up interfaces matching the pool network.

Common Exam Trap

If you forget `ip dhcp excluded-address`, the router may lease out its own IP, causing duplicate IPs and client connectivity issues.

DHCP Relay (Helper Address) and show Commands

Why DHCP Relay?

Broadcast DHCP messages do not cross routers. In larger networks, a relay agent forwards these to a centralized DHCP server.

ip helper-address

On the VLAN or router interface, configure `ip helper-address <DHCP-server-IP>` so the device forwards DHCP broadcasts as unicast.

Relay Behavior

The relay listens on UDP 67/68 and other ports, encapsulates the broadcast into a unicast packet, and sends it to the configured server.

Useful show Commands

`show ip dhcp binding`, `show ip dhcp pool`, and `show running-config | section dhcp` help you verify leases, utilization, and configuration.

Typical Misconfigurations

Missing or incorrect `ip helper-address` on the gateway interface is a classic reason clients fail to obtain DHCP leases in multi-VLAN networks.

DNS Fundamentals: Records, Resolution, and Caching

DNS as a Database

DNS is a hierarchical, distributed database. It stores records that map names to IPs and other information about domains.

Key Record Types

Important records: A (name to IPv4), AAAA (name to IPv6), CNAME (alias), and MX (mail servers). CCNA focuses mainly on A records.

Resolution Flow

A client asks its DNS server. If not cached, the server recursively queries root, TLD, then authoritative servers, then returns the answer.

Caching and TTL

Answers include a TTL. Resolvers cache results until TTL expires, which speeds up repeat lookups and reduces DNS query volume.

Client’s View

From a host’s perspective, the main question is: which DNS server IP should I query? That IP is usually learned from DHCP options.

Thought Exercise: Diagnosing Client Issues

Work through these scenarios mentally (or jot notes). Focus on symptoms and which component (DHCP vs DNS vs routing) is likely at fault.

Scenario 1: No IP Address

  • A Windows client shows `169.254.x.x` (APIPA) as its IPv4 address.
  • It cannot ping its default gateway.

Questions:

  1. Which part of DORA likely failed?
  2. Is this more likely a DHCP or DNS problem?
  3. What would you check on the Cisco router/switch first?

Think: a 169.254.x.x address means it did not receive a lease from DHCP at all.

Scenario 2: IP OK, Names Fail

  • A client has IP 192.168.50.101/24, default gateway 192.168.50.1.
  • It can `ping 8.8.8.8` successfully.
  • `ping google.com` fails with "could not find host".

Questions:

  1. Is DHCP working at least partially?
  2. Is routing likely OK or broken?
  3. Which setting in the DHCP scope would you suspect?

Hint: If direct IP pings work but names do not, suspect DNS server configuration.

Scenario 3: Some Sites Work, Some Do Not

  • Client can browse some websites but not others.
  • Other clients on the same subnet are fine.

Questions:

  1. Could this be a DHCP problem? A DNS problem? Both?
  2. What local client commands would you run to investigate (on Windows or Linux)?

Use this to practice mapping symptoms to layers: address assignment (DHCP), name resolution (DNS), and reachability (routing/NAT).

Quick Check: DHCP Concepts

Answer this question to confirm your understanding of DHCP behavior on Cisco routers.

A Cisco router is configured with a DHCP pool for 192.168.30.0/24 and `ip dhcp excluded-address 192.168.30.1 192.168.30.20`. Clients on that subnet are not receiving IP addresses. Which of the following is the MOST likely cause?

  1. The router interface for 192.168.30.0/24 is administratively down.
  2. The excluded-address range overlaps with the DHCP pool network.
  3. The DHCP pool is missing a `default-router` statement.
  4. The DHCP pool is missing a `dns-server` statement.
Show Answer

Answer: A) The router interface for 192.168.30.0/24 is administratively down.

If clients receive no address at all, a very common cause is that the router interface in that subnet is down, so it never hears DHCPDISCOVER broadcasts. Overlapping excluded addresses are allowed (they simply reduce available leases). Missing `default-router` or `dns-server` would still allow leases; clients would just lack those options.

Quick Check: DNS vs Routing

Use this question to distinguish DNS failures from routing failures.

A host receives its IP settings via DHCP and shows IP 10.1.1.50/24, default gateway 10.1.1.1, DNS server 10.1.10.10. The host can ping 8.8.8.8, but `ping example.com` fails with "unknown host". Which component is MOST likely misconfigured?

  1. The default gateway address in the DHCP pool
  2. The DNS server address in the DHCP pool
  3. The subnet mask in the DHCP pool
  4. NAT configuration on the edge router
Show Answer

Answer: B) The DNS server address in the DHCP pool

Because the host can ping 8.8.8.8, basic IP configuration, default gateway, and NAT are functioning. The failure to resolve names points directly to a DNS issue, most likely an incorrect or unreachable DNS server IP distributed by DHCP.

Client-Side Troubleshooting: Commands and Logic

Windows Tools

Use `ipconfig /all` for full IP details, `ipconfig /release` and `/renew` to restart DHCP, and `nslookup` to test DNS name resolution.

Linux/macOS Tools

Commands like `ip addr`, `nmcli device show`, `dig`, and `nslookup` reveal IP and DNS configuration and help test queries.

Step 1: Address Check

First, confirm the client has a valid IP in the correct subnet, not 169.254.x.x. If not, suspect DHCP failure or link issues.

Step 2–4: Gateway and Reachability

Verify the default gateway is set and pingable. Then ping an external IP (e.g., 8.8.8.8) to confirm routing and NAT health.

Step 5: DNS Focus

If IP pings work but hostnames fail, inspect the configured DNS server and use `nslookup` to pinpoint resolution problems.

Key DHCP and DNS Terms Review

Flip through these flashcards to reinforce core definitions and concepts.

DHCP (full definition)
The Dynamic Host Configuration Protocol (DHCP) automatically assigns IP configuration parameters such as IP address, subnet mask, default gateway, and DNS servers to clients.
DNS (full definition)
The Domain Name System (DNS) is a distributed database that maps human-readable hostnames to IP addresses and other resource records.
default gateway (definition)
A default gateway is the IP address of a router interface on the local network segment that a host uses to send traffic destined for remote networks.
DORA in DHCP
Discover, Offer, Request, Acknowledge – the four-step exchange between a DHCP client and server when obtaining a lease.
DHCP lease
A time-limited assignment of an IP address and configuration options to a client. The client must renew it before expiration or stop using the address.
DHCP relay (ip helper-address)
A function on routers/L3 switches that listens for DHCP broadcasts and forwards them as unicast packets to a remote DHCP server specified by `ip helper-address`.
A record (DNS)
A DNS record type that maps a hostname to an IPv4 address.
CNAME record (DNS)
A DNS record that creates an alias from one hostname to another canonical hostname.
Typical DNS symptom
If a host can ping external IP addresses but cannot resolve or ping hostnames, DNS configuration or availability is likely the problem.
Command: show ip dhcp binding
Cisco IOS command that displays the current DHCP leases (bindings) including client IP, MAC address, and lease expiration.

Key Terms

DNS
The Domain Name System (DNS) is a distributed database that maps human-readable hostnames to IP addresses and other resource records.
DHCP
The Dynamic Host Configuration Protocol (DHCP) automatically assigns IP configuration parameters such as IP address, subnet mask, default gateway, and DNS servers to clients.
DORA
Discover, Offer, Request, Acknowledge – the four-step DHCP exchange used when a client initially obtains an IP configuration.
APIPA
Automatic Private IP Addressing; a fallback addressing scheme (169.254.0.0/16) used by some operating systems when DHCP fails.
A record
A DNS record that maps a hostname to an IPv4 address.
DHCP lease
A time-limited assignment of an IP address and configuration options to a client, which must be renewed before expiration.
DHCP relay
A function on routers or Layer 3 switches that forwards DHCP broadcasts from clients to a remote DHCP server using unicast, typically configured with `ip helper-address`.
CNAME record
A DNS record that maps one hostname (an alias) to another canonical hostname.
default gateway
A default gateway is the IP address of a router interface on the local network segment that a host uses to send traffic destined for remote networks.
TTL (Time To Live)
A value in DNS records that specifies how long a resolver may cache the record before discarding it.

Finished reading?

Test your understanding with a custom practice exam on this chapter.

Test yourself