Objective 4.3

Explain the role of DHCP and DNS within the network

Interactive

DHCP: Discover, Offer, Request, Ack

A client with no address, a router acting as relay, a server two subnets away. Follow the four messages and the two fields that make relay work: the broadcast destination and giaddr.

10.1.20.0/2410.1.100.0/24Clientno addressR110.1.20.110.1.100.1DHCP server10.1.100.5
Message
Source IP
Destination IP
giaddr (relay)
Client addressnone

1/7 A laptop boots on VLAN 20 with no address. The DHCP server is on a different subnet, two routers away, so its broadcast alone would never get there.

4.3 DHCP: automatic addressing

Every host needs at least four things to use an IP network: an IP address, a subnet mask, a default gateway, and a DNS server address. Typing these into hundreds of laptops and phones by hand would be slow, error-prone (duplicate addresses), and impossible for visiting devices. Dynamic Host Configuration Protocol (DHCP) lets a server hand out this information automatically, on request, for a limited time called a lease.

DHCP uses UDP. The server listens on port 67 and the client listens on port 68. Because a brand-new client has no IP address, it must use broadcasts to find a server, which is why DHCP is closely tied to the broadcast domain (the VLAN or subnet).

The DORA exchange

A client obtaining a fresh address goes through four messages, remembered by the acronym DORA:

Step Message Sent by Source IP / Dest IP Purpose
D Discover Client 0.0.0.0 to 255.255.255.255 (broadcast) “Is there any DHCP server out there?”
O Offer Server Server IP to 255.255.255.255 (broadcast, or unicast if client asks) “Here is an address you could have.”
R Request Client 0.0.0.0 to 255.255.255.255 (broadcast) “I accept that offer” (also tells other servers their offers are declined)
A Acknowledgment Server Server IP to 255.255.255.255 (broadcast, or unicast) “It is yours for this lease period; here are your options.”

Why is the Request a broadcast even though the client now knows the server’s address? Because several servers might have sent Offers, and the broadcast Request lets every server see which one won so the others can free their tentative addresses. The Offer and Ack are usually broadcast too, because the client does not yet have an address and may not accept a unicast to an IP it has not finished configuring. A client can set a “broadcast flag” bit to control this; the details are not on the exam, but the fact that the Discover and Request are always broadcasts is.

When a lease is halfway through (T1 timer, 50% of the lease), the client sends a unicast Request directly to the server to renew. If that fails, at 87.5% (T2) it broadcasts. If the lease expires with no renewal, the client must stop using the address and start over with Discover. Renewal is faster and quieter than the full four-step exchange.

Other messages you may see: DHCP NAK (server refuses a request, for example the client is asking for an address that no longer belongs to this subnet), DHCP Release (client gives up its address, as when you run ipconfig /release), and DHCP Decline (client detected a duplicate address).

DHCP options

Beyond the address and mask, the server provides extra settings as numbered options. The ones the exam cares about:

Option Name What it carries
1 Subnet mask The mask for the assigned address
3 Router Default gateway address(es)
6 Domain name server DNS server address(es)
15 Domain name Domain suffix (e.g., example.com)
51 Lease time How long the address is valid
150 TFTP server Cisco IP phones use this to find the CUCM/TFTP server for their configuration files

Option 150 is Cisco-specific: when a Cisco IP phone boots, it uses DHCP to learn its address and option 150 to find the TFTP server that holds its firmware and configuration. (Option 66, the standard “TFTP server name,” is the vendor-neutral equivalent.)

Configuring a Cisco router as the DHCP server

Small sites often use the router itself as the DHCP server. The steps are: exclude addresses you assigned statically (gateway, servers, printers), then create a pool.

! Never hand out these addresses (gateway, servers, printers)
R1(config)# ip dhcp excluded-address 192.168.1.1 192.168.1.20
! Create a pool for the LAN
R1(config)# ip dhcp pool LAN-POOL
R1(dhcp-config)# network 192.168.1.0 255.255.255.0
R1(dhcp-config)# default-router 192.168.1.1
R1(dhcp-config)# dns-server 8.8.8.8 8.8.4.4
R1(dhcp-config)# domain-name example.com
! Lease: days hours minutes (default is 1 day)
R1(dhcp-config)# lease 0 12 0
! Optional: TFTP server for IP phones
R1(dhcp-config)# option 150 ip 192.168.1.5

ip dhcp excluded-address is a global command (it applies to every pool), and it takes a single address or a start and end range. Everything in network that is not excluded is fair game. The router chooses the pool by matching the incoming request’s subnet against the pool’s network statement: a request that arrives on Gi0/0 (192.168.1.1/24) gets addresses from the pool whose network contains 192.168.1.0/24.

Verifying the DHCP server

R1# show ip dhcp binding
Bindings from all pools not associated with VRF:
IP address      Client-ID/              Lease expiration        Type
                Hardware address/
                User name
192.168.1.21    0100.1122.3344.55       Sep 09 2026 02:30 AM    Automatic
192.168.1.22    0100.aabb.ccdd.ee       Sep 09 2026 02:41 AM    Automatic

The binding table lists every address currently leased, the client’s identifier (the 01 prefix means Ethernet, followed by the MAC), and when the lease expires.

R1# show ip dhcp pool
Pool LAN-POOL :
 Utilization mark (high/low)    : 100 / 0
 Subnet size (first/next)       : 0 / 0
 Total addresses                : 254
 Leased addresses               : 2
 Excluded addresses             : 20
 Pending event                  : none
 1 subnet is currently in the pool :
 Current index        IP address range                    Leased/Excluded/Total
 192.168.1.23         192.168.1.1      - 192.168.1.254    2     / 20    / 254

Also useful: show ip dhcp conflict (addresses the server found already in use via ping before assigning) and show ip dhcp server statistics (counts of each message type).

4.3 DNS: turning names into addresses

Humans remember www.cisco.com; routers forward on 72.163.4.185. The Domain Name System (DNS) is the distributed database that maps names to addresses (and back). Without DNS, the Internet still works, but nobody could use it.

The DNS hierarchy

DNS names are hierarchical, read right to left:

  • The root (written as a trailing dot, usually invisible) is the top. Thirteen root server groups know where every top-level domain lives.
  • Top-level domains (TLDs) such as .com, .org, .uk.
  • Second-level domains such as cisco.com, owned by organizations.
  • Subdomains and hosts such as www.cisco.com or mail.sales.cisco.com.

Each level is served by authoritative name servers that hold the official records for that zone. No single server knows every name; instead, servers know who to ask next.

Recursive versus iterative queries

When your laptop wants www.example.com, it sends a recursive query to its configured DNS server (learned via DHCP option 6). “Recursive” means “give me the final answer; do whatever it takes.” That server, called a resolver, then performs iterative queries on your behalf: it asks a root server, which replies “I do not know, but here are the .com servers.” It asks a .com server, which replies “ask the example.com servers at this address.” It asks the example.com server, which returns the actual A record. The resolver caches the answer for the record’s time-to-live (TTL) and returns it to the laptop.

Query type Who sends it What it asks Typical answer
Recursive Client to its resolver “Give me the final answer” The address, or an error
Iterative Resolver to root/TLD/authoritative servers “Answer if you can, else tell me who to ask” A referral or the address

DNS record types

Record Full name Maps
A Address Name to IPv4 address
AAAA Quad-A Name to IPv6 address
CNAME Canonical name Alias name to another name (e.g., www to webserver1)
MX Mail exchanger Domain to the mail server(s) that accept its email, with priorities
PTR Pointer IP address to name (reverse lookup, under in-addr.arpa / ip6.arpa)
NS Name server Domain to its authoritative name servers
SOA Start of authority Zone to its primary server and administrative timers

DNS transport: UDP 53 and TCP 53

DNS queries and replies normally use UDP port 53 because they are small and a lost query is simply resent. TCP port 53 is used for zone transfers (copying a whole zone from a primary to a secondary server, which must be reliable and can be large) and for any response too large to fit in a UDP datagram (the client retries over TCP when it sees the truncated flag). Modern DNS also uses TCP more often for DNSSEC and encrypted variants, but for the exam: UDP 53 for normal queries, TCP 53 for zone transfers and large responses.

DNS on a Cisco router

A router is a DNS client only in the sense that you might type ping www.cisco.com and want it resolved. Three commands control that:

! Allow the router to resolve names (on by default)
R1(config)# ip domain-lookup
! Which DNS servers to ask (up to six)
R1(config)# ip name-server 8.8.8.8 8.8.4.4
! Domain suffix appended to unqualified names ("ping sw1" -> sw1.example.com)
R1(config)# ip domain-name example.com
! Static host entry, like a hosts file; checked before DNS
R1(config)# ip host SW1 192.168.1.2

ip domain-name does double duty: it is also required to generate RSA keys for SSH (section 4.8). Static ip host entries let you ping SW1 or ssh SW1 without any DNS server.

A very common annoyance: you mistype a command in EXEC mode, and the router assumes the unknown word is a hostname you want to Telnet to. It tries to resolve it via DNS and hangs for 30 seconds or more if no server answers. The fix is to turn name lookups off:

R1(config)# no ip domain-lookup

Many labs and production devices have this set because the router rarely needs DNS itself. (Newer IOS and IOS-XE spell the commands ip domain lookup and ip domain name without hyphens and rewrite the hyphenated form; both forms are accepted.)

Verification: show hosts displays static entries and the DNS cache; show running-config | include name-server confirms the servers.