What is DHCP?
Dynamic Host Configuration Protocol
DHCP (Dynamic Host Configuration Protocol) automatically gives devices an IP address, default gateway and DNS servers when they join a network.
Without DHCP every laptop, phone and printer would need its addressing typed in by hand, and two people could easily pick the same address. For IPv4, a client and server exchange four messages over UDP, with the server listening on port 67 and the client on port 68. The client broadcasts a Discover, a server answers with an Offer, the client sends a Request for that offer, and the server confirms with an Acknowledgement (often remembered as DORA). The address is a lease, not a gift: it expires after a set time, and the client normally tries to renew with the same server halfway through the lease. Extra settings travel as numbered options, such as option 3 for the router (default gateway) and option 6 for DNS servers. Because Discover is a broadcast, it does not cross routers, so a router on each subnet can act as a relay agent and forward requests to a central server.
On an office or home network the router or firewall usually runs the DHCP server, handing out addresses from a pool and keeping fixed reservations for devices like printers, matched by MAC address. Common problems include two DHCP servers on one LAN fighting each other, a pool that has run out, and clients that fall back to a self-assigned 169.254.x.x address when no server answers. IPv6 works differently: hosts usually build their own addresses with SLAAC and learn the default gateway from Router Advertisements, while DHCPv6 is optional and is also used for prefix delegation. The Office gateway lesson builds a DHCP service with split pools and a printer reservation on VyOS.
Lessons that use DHCP
- Office gateway: DHCP, DNS and VRRP on VyOSBeginner · 40 min
Two VyOS routers serving one office LAN: VRRP for a gateway that survives a router failure, DHCP with split pools and a printer reservation, and DNS forwarding. Then a real failover, the DNS outage it exposed, and the fix.
- Setting up VyOS with NATBeginner · 45 min
A VyOS router with a NAT interface for a private LAN and a public interface for a routed public subnet: plain routing, source NAT, port forwarding and the forward firewall that NAT isn't. Every output comes from a real VyOS lab.
- IPv6 on VyOS: setup and routingBeginner · 55 min
Number a site from an ISP's /48 on VyOS: WAN and blackhole routes, SLAAC with Router Advertisements, handing a /56 to a downstream router statically and with DHCPv6 prefix delegation, and the forward firewall IPv6 needs because there's no NAT. Every output comes from a real two-router VyOS lab.