dnsmasq(8)
A lightweight DNS forwarder and DHCP server for small networks and embedded systems.
Synopsis
dnsmasq [OPTION]...Description
dnsmasq is a small DNS and DHCP server designed for networks with up to 1000 clients. It can act as a caching DNS forwarder, DHCP server, TFTP server, and router advertisement daemon. Commonly used in home networks, embedded devices, and containerized environments.
The daemon reads its configuration from /etc/dnsmasq.conf and processes command-line options. It forwards DNS queries to upstream resolvers, caches results locally, and optionally provides DHCP address assignment and DNS names for local machines.
dnsmasq is particularly popular in projects like OpenWrt, Docker networks, and as a lightweight alternative to BIND and ISC DHCP on resource-constrained systems.
Common options
| Flag | What it does |
|---|---|
-c, --conf-file=FILE | read configuration from FILE instead of /etc/dnsmasq.conf |
-d, --no-daemon | run in foreground (do not fork into background) |
-q, --log-queries | log all DNS queries and replies to syslog |
-C, --conf-dir=DIR | include all .conf files in DIR |
--port=PORT | listen on PORT for DNS queries (default 53) |
--address=/domain/IP | return IP for specified domain (local DNS override) |
--dhcp-range=RANGE | enable DHCP with address range (e.g., 192.168.1.100,192.168.1.150) |
--dhcp-option=OPTION | send DHCP option to clients (e.g., gateway, DNS servers) |
--server=SERVER | set upstream DNS server (default uses /etc/resolv.conf) |
--listen-address=ADDR | listen only on specified IP address |
-u, --user=USER | run as unprivileged user after startup |
-g, --group=GROUP | run as unprivileged group after startup |
Examples
start dnsmasq in foreground with custom config file
dnsmasq -d -c /etc/dnsmasq.confresolve internal.local to 192.168.1.10 and log all DNS queries
dnsmasq --address=/internal.local/192.168.1.10 --log-queriesassign DHCP addresses in range with 12-hour leases, forward DNS to Google
dnsmasq --dhcp-range=192.168.1.100,192.168.1.200,12h --server=8.8.8.8listen only on localhost port 5053 (useful for containers)
dnsmasq --port=5053 --listen-address=127.0.0.1load all configs from directory and run in foreground for debugging
dnsmasq -C /etc/dnsmasq.d/ --no-daemonreload configuration without restarting the daemon
killall -HUP dnsmasqrun as authoritative DHCP server with specified range
dnsmasq --dhcp-authoritative --dhcp-range=10.0.0.50,10.0.0.150run in foreground as unprivileged dnsmasq user
dnsmasq --user=dnsmasq --group=dnsmasq -d