DHCP Server Configuration

A DHCP server hands out addresses, a gateway and DNS servers to hosts that join the network. The configuration is short, but one mistake, a second DHCP server on the same network, breaks things in ways that are hard to trace.

The scope

A scope is a network, a pool inside it, and the options clients receive. Keep the router and fixed addresses outside the pool, or the pool can hand them to someone else first.

dhcp-range=192.168.1.100,192.168.1.200,255.255.255.0,12h
dhcp-option=option:router,192.168.1.1
dhcp-option=option:dns-server,192.168.1.1

Fixed addresses

Match a MAC address to an IP address so a printer or server always gets the same one, and keep the address outside the pool.

dhcp-host=aa:bb:cc:00:11:22,192.168.1.10,printer

One DHCP server per network

If the router already runs DHCP, turn it off before starting another. Two servers answer at random and clients get inconsistent gateways and addresses.

dnsmasq or ISC

dnsmasq is small and also serves DNS; set port=0 for DHCP only. ISC dhcpd is the long-standing standalone server, with more options and a separate file per subnet. The same scope works in both.

Open the DHCP server generator

Frequently asked questions

What lease time should I use?

Twelve hours to a day suits a normal LAN. An hour or less suits a guest network where devices come and go.

Why does dnsmasq count a day as 24h?

dnsmasq takes seconds, minutes or hours, not days, so a day is written 24h.

How do I test the file?

dnsmasq --test -C file for dnsmasq, and dhcpd -t -cf file for ISC. Both check the syntax without starting the server.

Guides