DHCP

Learn how DHCP leases addresses and distributes gateway and DNS settings, including relay agents and common troubleshooting.

4 min read 6 lesson sections
  • #DHCP
  • #address lease
  • #DHCP relay
  • #UDP
  • #network configuration

The Dynamic Host Configuration Protocol (DHCP) lets a client obtain network configuration from a server instead of requiring every setting to be entered manually. A lease can provide an IPv4 address and prefix plus options such as a default gateway and DNS resolver. DHCP supplies configuration; it does not route packets or resolve names itself.

The IPv4 lease exchange

When a client has no usable address, it commonly broadcasts a Discover. A server may answer with an Offer; the client requests a chosen offer, and the server sends an Acknowledgment (ACK) that finalizes the lease. This four-message sequence is often called DORA. Renewal behavior is different from the initial exchange and can be unicast.

DHCPv4 uses UDP port 67 for servers and 68 for clients. Since broadcasts do not normally cross routers, a DHCP relay agent forwards client requests to a server on another subnet and relays the reply back. Each subnet needs the right scope or pool and relay configuration.

Scope, lease, and DNS settings

A scope defines the address range and configuration for a subnet. Administrators reserve addresses for infrastructure, exclude addresses assigned statically, and choose a lease duration suitable for the network. A reservation associates a client identifier with a planned address; it is still administered by DHCP.

DHCP options can advertise a default gateway and DNS resolvers. Some environments also coordinate DHCP updates with DNS, but dynamic DNS behavior depends on the server and policy. A client with a valid address can still fail if it receives the wrong gateway or resolver.

DHCPv6 is a separate protocol using UDP ports 546 and 547. IPv6 hosts may use Stateless Address Autoconfiguration (SLAAC), DHCPv6, or both for different configuration information; do not assume DHCPv4’s exact message flow or options apply to IPv6.

Troubleshooting safely

Check the client address, prefix, gateway, DNS resolver, lease status, and server logs. If a client has an automatic private IPv4 address or no expected lease, verify the VLAN/subnet, scope capacity, relay configuration, and whether the authorized server is reachable. Renewing a lease will not fix a missing scope or blocked relay path.

On Windows, ipconfig /all displays lease and server details; ipconfig /renew requests a renewal. On Linux, use the network manager’s status and logs because the DHCP client varies by distribution. Avoid changing a live server scope until you understand which clients depend on it.

Security and operations

An unauthorized DHCP server can hand out a misleading gateway or DNS resolver. Use network controls such as DHCP snooping where supported, restrict access to server interfaces, monitor leases, and document reservations and exclusions. DHCP does not authenticate every client as a trusted user; use separate network access controls for identity and authorization.

Practice

Draw the DORA exchange for a client and server on the same VLAN. Then place the server on another subnet: add a relay and show which device forwards the initial request. Explain why a client can receive an address yet still fail to reach the internet.

Trusted references