dnsmasq DHCP Config Generator
Generate a dnsmasq IPv4 DHCP scope with CIDR and pool checks plus reservations, client options and optional PXE lines for a review-ready config.{{ summaryTitle }}
{{ summaryLine }}
{{ summaryAnnouncement }}
{{ computation.values.config_text }}
The chart renderer is unavailable. The same counts remain available in the configuration ledger.
| Item | Value | Directive | Operator note | Copy |
|---|---|---|---|---|
| {{ row.item }} | {{ row.value }} | {{ row.directive }} | {{ row.note }} |
Before an IPv4 client can use a local network, it usually needs more than an address. A Dynamic Host Configuration Protocol (DHCP) lease can also provide the subnet mask, default router, DNS resolvers, domain search suffix, time servers, and routes that make the address useful. A mismatch in any one of those values can leave a client connected but unable to reach the expected services.
A DHCP scope joins three pieces of network planning. The subnet defines every address in the broadcast domain, the dynamic pool defines which usable host addresses may be leased, and reservations keep named devices at stable addresses. The pool endpoints are inclusive. Gateways, infrastructure, and fixed reservations are normally placed outside that interval so they cannot be handed to another client.
- CIDR prefix
- The number after the slash that states how many leading address bits identify the network.
- Network address
- The first address in the subnet; it identifies the subnet and is not assigned to a normal host.
- Broadcast address
- The final address in an ordinary IPv4 subnet; it is also excluded from the usable host range.
- Lease
- A time-limited address assignment and its accompanying client options.
dnsmasq combines DNS, DHCP, and optional network-boot services in one small daemon. That makes it useful on lab VLANs, router appliances, build networks, and small managed segments, but it also concentrates responsibility. The listening interface must be the one that receives client requests, and authoritative mode belongs only on a segment where this server is intended to own DHCP.
Optional client settings should describe the real network rather than a copied template. A wrong router can break off-subnet traffic; a wrong resolver can make working connections look down; a classless route can redirect only selected destinations. PXE adds another chain of dependencies because firmware type, DHCP architecture matching, TFTP paths, boot files, and file permissions must all agree.
- Separate address planning from service activation. Reserve infrastructure addresses before choosing the dynamic pool.
- Confirm that no other unintended DHCP authority can answer on the same broadcast domain.
- Use a short lease only for a real operational reason; dnsmasq enforces a two-minute minimum for IPv4 leases.
- Test syntax on the target host and renew a lease from an isolated client before broad rollout.
Static checks can catch malformed addresses and obvious overlaps, but they cannot see live leases, relay behavior, VLAN placement, firewall rules, or the files available under a TFTP root. Deployment still needs host-level and on-wire verification.
How to Use This Tool:
Start from the approved subnet and interface. Add optional services only after the core address plan is clear.
- Enter the Listen interface and Scope network CIDR. Use a network from
/1through/30; if a host address is entered with the prefix, review the normalized network. - Set Dynamic pool start, Dynamic pool end, and Lease time. Both endpoints must be usable hosts inside the subnet, and the lower address must come first.
- Add the Router option, DNS servers, and any local domain settings. Leave the router blank only for an intentionally isolated segment.
- Enter fixed hosts as Static reservations in
MAC,IP,hostname,leaseorder. Open Advanced for NTP, classless routes, additional DHCP options, or PXE/TFTP. - Correct every blocking message, then read the configuration ledger and warnings. Test the copied file with
dnsmasq --teston the target host before restarting a service or renewing client leases.
Interpreting Results:
Dynamic leases is the inclusive size of the configured pool, not the number of addresses currently available. Existing leases, unmanaged devices, reservations, and another server can reduce practical capacity.
An error prevents configuration output because the address, duration, hostname, path, or directive token cannot be represented safely by the selected model. A warning allows output but marks an operational risk such as a gateway inside the pool, a duplicate reservation, a normalized CIDR, missing router or DNS options, or an unusually long interface name.
A ready result means no modeled error or warning remains. It does not prove that the daemon accepts distribution-specific includes, the interface exists, the process has permission to bind or read TFTP files, or clients receive a complete DHCP exchange.
Technical Details:
IPv4 subnet arithmetic converts dotted-quad addresses to unsigned 32-bit integers. The prefix creates a bit mask; bitwise AND finds the network address, while the network bits combined with the inverted mask find the broadcast address. Prefixes are limited to /1 through /30, so every accepted subnet has distinct network and broadcast addresses.
Formula Core:
For prefix length p, the modeled number of usable host addresses is:
The dynamic pool count uses the integer value of both inclusive endpoints:
| Symbol | Meaning | Unit |
|---|---|---|
| U | Usable subnet host addresses after excluding network and broadcast | addresses |
| p | CIDR prefix length | bits |
| L | Dynamic pool capacity | leases |
| S | Unsigned integer value of the pool start | address index |
| E | Unsigned integer value of the pool end | address index |
A /24 has 254 usable host addresses. The inclusive pool from 10.44.60.100 through 10.44.60.220 contains 121 possible dynamic leases.
Rule Core:
| Area | Blocking rule | Advisory review |
|---|---|---|
| Pool | Both endpoints are valid IPv4 usable hosts inside the subnet, with start less than or equal to end. | Router and fixed reservations should remain outside the inclusive pool. |
| Lease | Use a whole duration with s, m, h, d, or w, or use infinite; minimum is 120 seconds. |
Short leases increase renewal traffic and should match the segment's purpose. |
| Reservation | Six-octet MAC, usable IPv4 address, optional single-label hostname, and optional valid lease. | Duplicate MAC or IP values and addresses inside the pool are flagged. |
| Routes and options | Classless routes require destination CIDR,gateway; extra options require a supported name or code 0 to 255 plus conservative tokens without commas. |
A route gateway outside the client subnet needs an explicit reachability check. |
| PXE/TFTP | TFTP root must be an absolute safe path; BIOS and UEFI boot files must be safe relative tokens. | File existence, architecture fit, and service permissions remain live checks. |
Transformation Core:
The generated scope begins with the selected interface and optional binding, local-zone, and authoritative directives. The address plan becomes one dhcp-range line with start, end, netmask, and lease. Router, DNS, domain, NTP, and classless-route values become dhcp-option lines, while each valid fixed host becomes one dhcp-host line.
When PXE is enabled, the configuration turns on TFTP, sets the root, tags x86-64 EFI architecture values 7 and 9, selects the UEFI boot file for that tag, and leaves the BIOS boot file as the untagged fallback. This is a generated directive pattern, not proof that either boot artifact exists.
Limits and Privacy Notes:
- Configuration generation and address arithmetic use the values in the browser; no live network or dnsmasq service is queried.
- Generated text can reveal internal subnets, MAC addresses, hostnames, routes, DNS servers, and network-boot infrastructure. Handle copied or downloaded material as operationally sensitive.
- Distribution packaging, include paths, daemon version, service ownership, firewall policy, security confinement, and relay topology can change whether the same text works on the target host.
- Do not enable authoritative DHCP on a shared segment until the intended server ownership is confirmed.
References:
- dnsmasq manual page, dnsmasq project.
- RFC 2131: Dynamic Host Configuration Protocol, IETF, March 1997.
- RFC 3442: The Classless Static Route Option for DHCPv4, IETF, December 2002.
- How to capture DHCP traffic with tcpdump, Simplified Guide.