Kokil Thapa - Professional Web Developer in Nepal
Freelancer Web Developer in Nepal with 15+ Years of Experience

Kokil Thapa is an experienced full-stack web developer focused on building fast, secure, and scalable web applications. He helps businesses and individuals create SEO-friendly, user-focused digital platforms designed for long-term growth.

DHCP Explained for System Administrators

By Kokil Thapa | Last reviewed: September 2026

Every laptop, phone, and server on your LAN needs an IP address before it can reach DNS, gateways, or your applications. DHCP Explained for System Administrators starts here: Dynamic Host Configuration Protocol hands out addresses and network parameters automatically so you do not manually configure hundreds of devices. On production Ubuntu servers I maintain for Linux system administration clients, DHCP sits beside DNS, firewall rules, and deployment pipelines as core infrastructure. This guide walks through the protocol, Linux server setup, scopes, and the failures that actually show up after office moves or VLAN changes.

What is DHCP and why do system administrators rely on it?

DHCP is defined in RFC 2131 and extended by later RFCs for options like vendor classes and relay behaviour. A DHCP server maintains a pool of usable addresses and leases them for a defined time. When a lease expires, the address returns to the pool unless the client renews.

Without DHCP, each device needs a static IP, subnet mask, default gateway, and DNS servers typed by hand. That works for three servers. It breaks at thirty workstations and becomes a nightmare at three hundred. DHCP centralises those values in one configuration file or database.

System administrators use DHCP because it scales onboarding. A new employee connects to Wi-Fi and gets a valid address in seconds. You change the default gateway once on the server instead of visiting every machine. For domain registration and hosting projects where office LANs feed into web servers, consistent gateway and DNS settings prevent subtle routing bugs.

DHCP Network TopologyClientsLaptop, phone, VMRelay AgentRouter or L3 switchDHCP ServerKea, dnsmasq, ISCDNS ResolverInternal or publicServer returns IP, mask, gateway, DNS, lease time
DHCP explained for system administrators: clients, relay agents, the DHCP server, and DNS form the typical production chain.

DHCP also carries options beyond the IP address. Option 3 is the default router. Option 6 lists DNS servers. Option 15 sets the DNS domain name. Option 51 defines lease time in seconds. Vendor-specific options can push NTP servers, PXE boot filenames, or VoIP settings.

On shared EC2 infrastructure where I run Deployer-based sites, office VLANs and staging subnets still depend on DHCP or closely managed static pools. The protocol is not glamorous. It is load-bearing.

How does the DHCP four-way handshake (DORA) work?

When a client boots or joins a network, it has no IP address. It sends a DHCPDISCOVER broadcast to 255.255.255.255 on UDP port 67. Every DHCP server on the segment hears it. Each server that can serve that subnet replies with DHCPOFFER, proposing an IP and options.

The client picks one offer and broadcasts DHCPREQUEST. That broadcast tells other servers their offers were declined. The chosen server responds with DHCPACK, confirming the lease. If the requested address is unavailable, the server sends DHCPNAK instead.

After ACK, the client configures its interface and may perform ARP checks to detect duplicate addresses. This sequence is called DORA: Discover, Offer, Request, Acknowledge.

Renewal and rebinding phases

Leases are temporary. At 50% of lease time (T1), the client unicasts DHCPREQUEST to the original server to renew. At 87.5% (T2), if renewal failed, the client broadcasts to any server on the segment. At expiry, the client must restart DORA from scratch.

Short leases suit guest Wi-Fi where devices come and go. Long leases suit stable server VLANs where churn is low. A common mistake is setting lease time to five minutes on a busy office LAN. That floods the server with renewal traffic.

DORA Handshake SequenceClientDHCP Server1. DISCOVER (broadcast)2. OFFER (proposed IP + options)3. REQUEST (accept one offer)4. ACK (lease confirmed)Client configures IP, mask, gateway, DNS
The DORA sequence is the core mechanism behind DHCP explained for system administrators in daily troubleshooting.

Capturing this traffic with tcpdump -i eth0 port 67 or port 68 resolves many "works on Wi-Fi, fails on Ethernet" tickets. You see whether DISCOVER leaves the client and whether OFFER returns. Related reading: SELinux basics for administrators when firewall contexts block DHCP relay replies.

How do you configure a DHCP server on Linux?

Linux offers several DHCP servers. ISC Kea is the modern successor to isc-dhcp-server. dnsmasq suits small office routers and hypervisor bridges. Windows Server and enterprise appliances use their own stacks, but the concepts transfer.

For a dedicated Ubuntu 24.04 host serving 192.168.10.0/24, Kea is a solid choice. Install it from your distribution packages, then define a subnet in JSON configuration.

Example Kea DHCPv4 configuration

{
  "Dhcp4": {
    "interfaces-config": {
      "interfaces": [ "eth0" ]
    },
    "subnet4": [
      {
        "subnet": "192.168.10.0/24",
        "pools": [
          { "pool": "192.168.10.100 - 192.168.10.200" }
        ],
        "option-data": [
          { "name": "routers", "data": "192.168.10.1" },
          { "name": "domain-name-servers", "data": "192.168.10.2, 8.8.8.8" },
          { "name": "domain-name", "data": "office.example.com" }
        ],
        "valid-lifetime": 86400
      }
    ],
    "lease-database": {
      "type": "memfile",
      "persist": true,
      "name": "/var/lib/kea/dhcp4.leases"
    }
  }
}

Validate syntax with kea-dhcp4 -t /etc/kea/kea-dhcp4.conf before restarting the service. Kea documentation at kea.readthedocs.io covers hooks, high availability, and PostgreSQL lease backends for larger deployments.

dnsmasq for lightweight setups

On a small office gateway, dnsmasq combines DNS caching and DHCP in one daemon. A minimal /etc/dnsmasq.d/lan.conf might look like this:

interface=eth0
dhcp-range=192.168.50.50,192.168.50.150,255.255.255.0,12h
dhcp-option=3,192.168.50.1
dhcp-option=6,192.168.50.1,1.1.1.1
dhcp-authoritative

The dhcp-authoritative flag tells clients this server is the sole authority on the segment. That speeds up boot when stale leases linger elsewhere.

DHCP relay across VLANs

DHCP broadcasts do not cross routers. When your DHCP server sits on VLAN 10 and clients live on VLAN 20, configure a relay agent on the L3 gateway. On Linux with dhcrelay or on Cisco IOS with ip helper-address, the relay forwards DISCOVER packets to the server's unicast address.

  1. Place the DHCP server on a management VLAN with routable access to all client subnets.
  2. Define one subnet block per VLAN in the server config.
  3. Enable relay on each VLAN interface pointing at the server IP.
  4. Open UDP 67/68 between relay and server through firewalls.
  5. Test with a client on each VLAN before closing the change ticket.

I have seen production outages where relay was configured but capacity planning ignored lease file growth on disk. Monitor lease database size the same way you monitor CPU and RAM.

What are DHCP scopes, reservations, exclusions, and options?

A scope (or subnet declaration) is the address range a server may assign within one broadcast domain. The pool must exclude network and broadcast addresses. For a /24, usable host addresses are typically .1 through .254 depending on design.

Reservations map a MAC address to a fixed IP inside the pool. The client still uses DHCP, but always receives the same address. Use reservations for printers, access points, and NAS boxes that other systems reference by IP. This beats pure static config because you change the reservation centrally.

Exclusions remove addresses from the dynamic pool without assigning them. Reserve 192.168.10.1 for the gateway and exclude it from the pool so the server never leases it to a laptop.

ConceptPurposeTypical useAdmin tip
Scope / poolDynamic address rangeEmployee laptops, guest devicesSize pool for peak devices plus 20% headroom
ReservationFixed IP via DHCPPrinters, APs, camerasDocument MAC-to-role in your IPAM sheet
ExclusionAddress withheld from poolGateway, broadcast, future serversExclude before go-live, not after a conflict
Option 66/67PXE boot server and filenameOS deployment VLANIsolate imaging VLAN from production

Kea reservations use host reservations keyed by hardware address:

"reservations": [
  {
    "hw-address": "aa:bb:cc:dd:ee:ff",
    "ip-address": "192.168.10.50",
    "hostname": "office-printer"
  }
]

Validate JSON structure with a JSON formatter before pushing config to production. A trailing comma in Kea JSON has caused more downtime than you might expect.

192.168.10.0/24 Scope Layout.1 GW.2–.9ExcludedDynamic Pool.100 – .200.50ReservedLease lifecycleAssign → T1 renew → T2 rebind → Expire → Reclaim
Scopes combine gateway addresses, exclusions, dynamic pools, and MAC reservations—the building blocks of DHCP explained for system administrators.

For multi-site businesses in Nepal, document scopes in a shared runbook alongside Nepali date converter utilities and other ops tools your team already uses daily. Consistency beats tribal knowledge when Dashain leave rotates staff.

How do you troubleshoot common DHCP failures in production?

DHCP problems look like "no internet" or "cannot reach internal apps." Users rarely report DHCP by name. Your job is to narrow the layer quickly.

Symptom: client gets 169.254.x.x (APIPA)

Windows and some Linux configs assign a link-local address when DHCP fails entirely. No DISCOVER reply reached the client, or every OFFER was rejected. Check cable, VLAN, relay, and whether the server service is running.

Symptom: duplicate IP conflicts

Someone statically configured .105 while the pool also leases .105. Exclude static ranges from the pool. Enable conflict detection if your server supports it. Kea can ping before ACK on some builds.

Symptom: pool exhausted

Every address is leased and none expired. Shorten lease time temporarily, expand the subnet, or prune stale reservations. On one client project, abandoned IoT devices held hundreds of week-long leases until we cut lifetime to four hours on that VLAN.

Diagnostic commands

# Linux client: release and renew
sudo dhclient -r eth0 && sudo dhclient -v eth0

# Inspect current lease
cat /var/lib/dhcp/dhclient.leases

# Server-side Kea lease list
kea-shell --host 127.0.0.1 --port 8000 --service dhcp4 \
  --command lease4-get-all

# Capture DHCP traffic
sudo tcpdump -ni eth0 'udp port 67 or udp port 68'

Cross-check firewall rules. AWS Systems Manager fleet automation does not replace on-prem DHCP, but hybrid teams often forget security groups block UDP 67 between VPC peers. The same logic applies to UFW on Ubuntu gateways.

Log correlation matters. Match MAC addresses from server logs to switch port maps. For sites I maintain with GitLab CI and Deployer, the app servers use static IPs while staff VLANs stay on DHCP. Mixing those models without documentation causes midnight pages.

DHCP Troubleshooting FlowNo IP obtained?Check L2 linkCheck relayCheck serverCapture tcpdump → verify DORA → fix configDocument scope change in runbook
A practical DHCP troubleshooting decision path: link layer, relay agent, then server before deep packet analysis.

Pair DHCP monitoring with broader health checks from support and maintenance contracts. Alert when pool utilisation crosses 85%. That gives you time to expand before users notice.

When should you use DHCP versus static IP addresses?

Not every device belongs in a dynamic pool. Production database servers, load balancers with fixed DNS records, and infrastructure that must survive DHCP outages often deserve static configuration or reservations.

  • Use DHCP for workstations, mobile devices, guest networks, and lab VMs with short lifetimes.
  • Use reservations when a device needs a predictable IP but you still want central control.
  • Use static IPs on servers referenced in firewall rules, TLS certificates, or hard-coded API allowlists where a lease change would break integrations.
  • Use DHCP options to push NTP and DNS rather than baking them into golden images.

On Notary Kathmandu and sister legal-tech sites sharing a Deployer pipeline, web servers sit on static addresses behind a reverse proxy. Office staff remain on DHCP. That split is deliberate and documented.

Cloud VPCs blur the line. AWS assigns private IPs at ENI creation time, which behaves like static from the instance perspective. You still automate allocation via infrastructure-as-code. The mental model matches reservations: predictable, centrally managed, auditable.

For Kubernetes clusters, CKA prep guides stress stable node networking. Worker nodes may DHCP on bare metal labs, but production clusters almost always use fixed addressing or CNI-managed IPs independent of traditional DHCP pools.

Security considerations belong here too. Rogue DHCP servers on a flat LAN can redirect clients to malicious gateways. Enable DHCP snooping on managed switches. Restrict who can attach unknown routers to office ports. RFC 3118 covers authentication extensions, but most SMB networks rely on VLAN segmentation and port security instead.

High availability pairs two DHCP servers with split scopes or Kea HA hooks. Each server owns half the pool, or they share a lease database backend. Failover testing should be scheduled. A backup server that never claimed leases will not help during a Friday outage.

IPv6 adds DHCPv6 and SLAAC. Many admins run router advertisements for address assignment and DHCPv6 only for DNS options (stateless DHCPv6). Dual-stack planning is its own topic, but the administrator mindset matches IPv4: define pools, document reservations, monitor utilisation.

Cost is negligible for software. Kea and dnsmasq are free. Your expense is engineer time for design, documentation, and incident response. Budget roughly Rs 15,000–40,000 (~USD 110–300) for a consultant to audit a multi-VLAN office if your internal team lacks networking depth. That is cheaper than a day of company-wide downtime.

Integrate DHCP changes into change management. A wrong default gateway in option 3 affects every renewal on that scope. Use a regex tester to validate hostname patterns in dynamic DNS updates if you couple DHCP with BIND or Windows DNS.

Developers building LAN-connected apps should understand lease behaviour. A long-running desktop app that caches an IP at startup may break when the OS renews mid-session if the app assumes immutability. Server-side apps on web development stacks rarely touch DHCP directly, but IoT integrations and office printing workflows do.

Backup lease databases nightly if you use file-backed storage. After server rebuild, an empty lease file means mass reassignments and possible conflicts until clients renew. PostgreSQL backends simplify restore but add dependency management aligned with Well-Architected reliability practices.

Performance tuning rarely limits DHCP unless you serve tens of thousands of clients from one daemon. CPU load spikes during Monday morning boot storms. Spread lease times slightly with randomisation if your server supports it. That avoids synchronized mass renewals at the top of each hour.

Documentation templates should list scope name, VLAN ID, subnet, pool range, gateway, DNS, lease time, relay IP, and owner. Link to your portfolio infrastructure projects only when explaining real multi-site patterns, not as filler. Operators reading system design interview prep material will recognise DHCP as a small but critical dependency in overall topology diagrams.

Finally, test guest and IoT VLANs separately from corporate SSIDs. IoT devices often assume /24 networks and break on restrictive options. A printer that ignores option 6 and uses hard-coded Google DNS will bypass your split-tunnel VPN policies. DHCP pushes policy, but clients choose whether to obey.

Key Takeaways

  • DHCP automates IP, gateway, and DNS assignment through the DORA handshake—know it before you debug "no network" tickets.
  • Define scopes with clear pools, exclusions, and MAC reservations; never let dynamic pools overlap static infrastructure addresses.
  • Use relay agents when the DHCP server and clients sit on different VLANs; verify UDP 67/68 end to end.
  • Monitor pool utilisation and lease database health; alert at 85% capacity before users hit APIPA addresses.
  • Reserve static or reserved IPs for servers in firewall rules; use DHCP for workstations and transient devices.
  • Capture tcpdump on port 67/68 when logic says the server is fine but clients still fail—packets do not lie.

People Also Ask

What ports does DHCP use?

DHCP clients send from UDP port 68 to server port 67. Relay agents forward between segments on the same ports. Firewalls must allow this traffic between clients, relays, and servers or discovery never completes.

How long should a DHCP lease time be?

Guest Wi-Fi often uses 1–4 hours. Corporate LANs commonly use 8–24 hours. Stable device VLANs may use multiple days. Shorter leases reclaim addresses faster but increase server traffic.

Can two DHCP servers share one scope?

Yes, with split scopes or HA failover where each server holds a non-overlapping portion of the pool, or both share a central lease database. Never run two independent servers assigning from the same full range without coordination.

What is the difference between DHCP and DNS?

DHCP assigns IP configuration to clients. DNS resolves hostnames to addresses. DHCP option 6 tells clients which DNS servers to use—they work together but serve different roles in network stack setup.

Build reliable infrastructure from the ground up

DHCP explained for system administrators is foundational knowledge, not a footnote. You will configure scopes on day one and debug them after every office expansion. Pair solid DHCP design with documented VLAN maps, monitored lease pools, and tested failover before you need it. If your team wants help auditing office networks, cloud VPCs, or the Linux hosts that sit behind them, review our Linux administration services or reach out through contact us to plan a stable baseline for 2026 and beyond. More infrastructure reading lives on the blog, including guides for startup infrastructure and about the engineer behind these deployments. See also customer reviews and testing and optimization for post-launch reliability work.

Frequently Asked Questions

DHCP (Dynamic Host Configuration Protocol, RFC 2131) lets a central server lease IP addresses, subnet masks, gateways, and DNS to clients automatically. Without it, every device needs manual network settings—a workable approach for a handful of servers but unmanageable at office scale. System administrators use DHCP because it speeds onboarding, centralises gateway and DNS changes, and cuts addressing errors on LANs that feed into production web and hosting infrastructure.

DORA is Discover, Offer, Request, Acknowledge. A client with no IP broadcasts DHCPDISCOVER to 255.255.255.255 on UDP port 67. Servers reply with DHCPOFFER. The client broadcasts DHCPREQUEST to accept one offer. The chosen server sends DHCPACK confirming the lease, or DHCPNAK if the address is unavailable.

For a dedicated Ubuntu 24.04 host, ISC Kea is the recommended modern choice over legacy isc-dhcp-server. Install from distribution packages, define subnets and pools in JSON at /etc/kea/kea-dhcp4.conf, set routers, domain-name-servers, and valid-lifetime, then validate syntax with kea-dhcp4 -t before restarting the service. For small office gateways, dnsmasq combines DNS caching and DHCP in a single lightweight daemon with a simpler configuration file.

Kea suits dedicated DHCP servers on Ubuntu 24.04 serving multiple subnets, supports PostgreSQL lease backends, hooks, and high-availability pairs for larger deployments. dnsmasq fits small office routers and hypervisor bridges where you want DNS caching and DHCP in one process. Both are free; the choice depends on scale, VLAN count, and whether you need enterprise features like shared lease databases rather than raw licensing cost.

A scope is the address range a server may assign within one broadcast domain. Reservations map a MAC address to a fixed IP inside the pool—ideal for printers, access points, and NAS boxes referenced by other systems. Exclusions remove addresses from the dynamic pool without assigning them, such as reserving the gateway IP so the server never leases it to a laptop. Together they define how addresses are allocated on each VLAN.

DHCP broadcasts do not cross routers. When the server sits on VLAN 10 and clients live on VLAN 20, configure a relay agent on the L3 gateway using Linux dhcrelay or Cisco ip helper-address pointing at the server's unicast IP. Define one subnet block per VLAN on the server, enable relay on each VLAN interface, and open UDP ports 67 and 68 between relay and server through firewalls. Test a client on each VLAN before closing the change ticket.

That is APIPA—a link-local address assigned when DHCP fails entirely. No DISCOVER reply reached the client, or every OFFER was rejected. Check physical link, VLAN membership, relay configuration, and whether the DHCP server service is actually running on the segment before chasing application-layer problems.

Start at the link layer, then relay, then server. On Linux clients run sudo dhclient -r eth0 followed by sudo dhclient -v eth0 to release and renew. Inspect leases with cat /var/lib/dhcp/dhclient.leases. On Kea servers list active leases via kea-shell. Capture traffic with sudo tcpdump -ni eth0 'udp port 67 or udp port 68' to confirm DISCOVER leaves the client and OFFER returns. Cross-check UFW or cloud security groups blocking UDP 67 between VLAN peers.

Use DHCP for workstations, mobile devices, guest networks, and lab VMs. Use reservations when a device needs a predictable IP but you want central control—printers and cameras are typical cases. Use static IPs on production database servers, load balancers, and infrastructure referenced in firewall rules, TLS certificates, or hard-coded API allowlists where a lease change would break integrations. Many production setups deliberately split: app servers static, staff VLANs on DHCP.

Option 3 sets the default router (gateway). Option 6 lists DNS servers. Option 15 sets the DNS domain name. Option 51 defines lease time in seconds—the article example uses 86400 for a one-day lifetime. Options 66 and 67 push PXE boot server and filename for OS deployment VLANs. Vendor-specific options can also deliver NTP servers or VoIP settings. Changing option 3 on a live scope affects every client at next renewal, so treat it as a change-management event.

Kea and dnsmasq are free. Real expense is engineer time for design, documentation, and incident response—budget roughly Rs 15,000–40,000 (~USD 110–300) for a consultant to audit a multi-VLAN office if your internal team lacks networking depth.

Short leases suit guest Wi-Fi where devices come and go. Long leases suit stable server VLANs with low churn. A common mistake is five-minute leases on a busy office LAN—that floods the server with renewal traffic. At 50% of lease time (T1) clients unicast to renew; at 87.5% (T2) they broadcast if renewal failed. Abandoned IoT devices holding week-long leases can exhaust a pool until you shorten lifetime on that VLAN.

Rogue DHCP servers on a flat LAN can redirect clients to malicious gateways. Enable DHCP snooping on managed switches and restrict unknown routers on office ports. RFC 3118 covers authentication extensions, but most SMB networks rely on VLAN segmentation and port security instead. Place the authoritative server on a management VLAN with routable access to client subnets, and document which interfaces are allowed to serve addresses.

Alert when pool utilisation crosses 85%—that gives time to expand the subnet or prune stale reservations before every address is leased. On Kea with file-backed storage, monitor lease database disk growth the same way you monitor CPU and RAM. Match MAC addresses from server logs to switch port maps. Backup lease databases nightly; after a server rebuild, an empty lease file means clients must renegotiate every address.

High availability pairs two DHCP servers with split scopes or Kea HA hooks sharing a lease database backend. Each server may own half the pool, or both synchronise leases through PostgreSQL or similar backends. Failover testing must be scheduled—a backup server that never claimed leases will not help during a Friday outage. For single-subnet small offices, one well-monitored Kea or dnsmasq instance is often enough; multi-VLAN production networks with no addressing downtime tolerance justify HA investment.

Share this article

0 Comments

Leave a comment

Your email is not published. Comments appear once they have been read. Sign in to have your details filled in.

Quick Contact Options
Choose how you want to connect me: