Skip to content

Module 9: Dynamic Host Configuration Protocol (DHCP)

A device needs several settings before it can communicate on an Internet Protocol version 4 (IPv4) network. You could enter those settings by hand, but doing that for every laptop, phone, printer, and virtual machine would be slow and easy to get wrong.

The Dynamic Host Configuration Protocol (DHCP) supplies those settings automatically.

  • What DHCP gives a client
  • How a new client requests an IPv4 configuration
  • How leases and reservations work
  • What a 169.254.x.x address means

A device asking for network settings is a DHCP client. The service answering it is a DHCP server.

The server commonly supplies:

Setting Why the client needs it
IPv4 address Identifies the client’s interface on the network
Subnet mask Tells the client which IPv4 destinations are local
Default gateway Provides a path to destinations outside the local subnet
Domain Name System (DNS) server addresses Tell the client where to send name-resolution requests
Lease time States how long the client may use the address

These settings must work together. A client can have a valid-looking address but still fail to reach other networks because it received the wrong mask or gateway. It may also reach Internet Protocol (IP) addresses successfully while names fail because it received the wrong DNS settings.

The DHCP server keeps a range of addresses available for clients. This range is often called a pool or scope. When the server assigns one of those addresses, it records a lease so it does not give the same address to another client.

DHCP is a service or role, not one particular type of physical device. Many different systems can run it.

DHCP provider Where you might see it
Home router or Wi-Fi gateway Supplies settings to phones, computers, televisions, and other home devices
Network device or server Supplies settings to one or more business networks
Virtualization or cloud network service Supplies settings to virtual machines and other virtual resources

In this guide’s lab, Oracle VirtualBox provides DHCP for the VirtualBox network address translation (NAT) Network named NETLAB. The Windows 11 virtual machine named WINCLIENT and the Linux Mint virtual machine named LINUXBOX are both DHCP clients.

Linux systems can also provide DHCP using software such as Kea or dnsmasq. The operating system or product is less important than the role it is performing:

DHCP client asks for settings -> DHCP server supplies settings

Avoid running unrelated DHCP servers on the same subnet. A client may accept an offer from the wrong server and receive an incorrect address, gateway, or DNS configuration. Organizations can use multiple DHCP servers for planned redundancy, but those servers must be configured to work together.

A new DHCP client has two immediate problems:

  • It does not have a usable IPv4 address.
  • It may not know the DHCP server’s IPv4 address.

Dynamic Host Configuration Protocol version 4 (DHCPv4) uses the User Datagram Protocol (UDP). The client sends a local broadcast that every device on the subnet can receive:

Source IPv4 address (unconfigured client): 0.0.0.0
Source UDP port (DHCP client): 68
Destination IPv4 address (local broadcast): 255.255.255.255
Destination UDP port (DHCP server): 67

The DHCP server replies from UDP port 67 to the client’s UDP port 68.

The Discover, Offer, Request, Acknowledgment (DORA) Exchange

Section titled “The Discover, Offer, Request, Acknowledgment (DORA) Exchange”

A client obtaining a new DHCPv4 lease normally completes four steps known as DORA.

Step Message Sent by Meaning
1 Discover Client Is a DHCP server available?
2 Offer Server I can offer this address and configuration.
3 Request Client I want to use the offered address.
4 Acknowledge Server The lease is approved.

The actual DHCP message names are DHCPDISCOVER, DHCPOFFER, DHCPREQUEST, and DHCPACK.

The offer includes more than an address. It can include the subnet mask, default gateway, DNS servers, lease duration, and other values called DHCP options.

More than one server can make an offer. The client’s request identifies the offer it selected so the other servers know that their offers were not accepted.

A DHCP lease lets a client use an address for a limited time. The client normally asks to renew the lease before it expires.

The first renewal attempt goes to the server that issued the lease. If that server does not answer, the client later broadcasts a request that another suitable DHCP server can answer. The client must stop using the address if the lease expires without being renewed.

This normally happens without interrupting the user. A renewal usually needs only a request and an acknowledgment; it does not repeat the complete DORA exchange.

A client may receive the same address after restarting or renewing. That is normal when the address remains available.

Both methods can give a device a predictable address:

Method Where it is configured How the client receives its settings
DHCP reservation On the DHCP server The client still uses DHCP
Static address On the client device An administrator enters the settings manually

A reservation tells the DHCP server to give a particular client the same address. It is useful for printers, servers, and other devices that should remain predictable while still receiving centrally managed settings.

A static address does not come from DHCP. Manually assigned addresses should be outside the dynamic pool or excluded from it. Otherwise, the server could lease that address to another device and create an address conflict.

The client’s initial broadcast stays on its local subnet. Routers do not normally forward broadcasts, so a DHCP server on another subnet would not receive it directly.

A DHCP relay listens for the local broadcast and forwards it to the real DHCP server:

Client broadcast -> DHCP relay -> DHCP server on another subnet

The relay also tells the server which subnet the request came from, allowing the server to select the correct address pool.

Routers, firewalls, and many layer 3 switches can act as DHCP relays. Windows Server can also provide a relay through its Remote Access role. The relay is an intermediary; it is not the server that owns the address pool.

If DHCP works on several subnets but fails on only one, check that subnet’s DHCP pool, virtual local area network (VLAN), and relay configuration.

When a Windows client is configured to obtain an IPv4 address automatically but cannot obtain a normal DHCP lease, it may assign itself an address such as:

169.254.36.8

Windows calls this Automatic Private IP Addressing (APIPA). The standards term is an IPv4 link-local address.

An IPv4 link-local address can communicate only with compatible devices on the same local link. Routers do not forward it to other networks or the internet.

Seeing 169.254.x.x usually means:

This interface did not obtain its expected IPv4 configuration.

It is a clue, not the complete diagnosis. The cause could be the network connection, VLAN, DHCP server, relay, or an empty address pool.

On Windows, run:

ipconfig /all

Find the active network adapter and identify:

  • DHCP Enabled
  • IPv4 Address
  • Subnet Mask
  • Default Gateway
  • DHCP Server
  • DNS Servers
  • Lease Obtained
  • Lease Expires

Do not assume that the first adapter is the active one. Virtual private network (VPN) and virtualization software can create several adapters.

On Linux, these commands show the assigned IPv4 addresses, routes, and current DNS configuration:

ip -4 addr
ip route
cat /etc/resolv.conf
Symptom What to check
Address begins with 169.254 Network connection, VLAN, DHCP server, relay, and available pool
Correct address but no remote connectivity Subnet mask and default gateway
IP connections work but names fail DNS server addresses supplied by DHCP
Only one subnet cannot get leases That subnet’s pool and relay configuration
Duplicate-address warning Static addresses that overlap the DHCP pool

Record the current configuration before repeatedly releasing or changing it. The incorrect value may be the clue that identifies the problem.

  • The Dynamic Host Configuration Protocol (DHCP) automatically supplies network settings through time-limited leases.
  • The initial DHCP exchange works before a client has a complete IP configuration.
  • A 169.254.x.x address is a clue that the interface did not obtain its expected IPv4 configuration.

Continue to Module 10: Domain Name System (DNS) to see how DNS translates names into addresses.