AlmaLinux 10: a LAN DNS server with dnsmasq
Test scope
Section titled “Test scope”An AlmaLinux 10.2 Server VM with dnsmasq-2.90-7.el10_2 installed from the installation media (the lab has no internet).
Goal: make this host the LAN resolver for *.lab.test. Screenshot: public/evidence/dnsmasq/alma-server.png.
The whole configuration
Section titled “The whole configuration”listen-address=192.168.2.241bind-interfacesaddress=/lab.test/192.168.2.241local-ttl=60no-resolvlog-querieslisten-address+bind-interfaces: serve only on that address, avoiding port 53 conflicts;address=/lab.test/…: a wildcard — every*.lab.testresolves to the same address;local-ttl=60: TTL for those local records (the default is 0, see below);no-resolv: ignore/etc/resolv.confupstreams.
Bound to one address
Section titled “Bound to one address”$ ss -lunp | grep ':53 ' | head -1UNCONN 0 0 192.168.2.241:53 0.0.0.0:* users:(("dnsmasq",pid=16170,fd=4))It is 192.168.2.241:53, not 0.0.0.0:53 — proof that bind-interfaces took effect. The side effect: queries to 127.0.0.1 are refused, so verification must use the real address.
The TTL trap
Section titled “The TTL trap”$ dig @192.168.2.241 web.lab.test A +noall +answerweb.lab.test. 60 IN A 192.168.2.241Without local-ttl, the same record carries TTL 0:
web.lab.test. 0 IN A 192.168.2.241TTL 0 means no downstream cache may store it, including another dnsmasq, so every query returns to this server. In a forwarder topology that silently disables caching entirely — measured in the client-side page.
Unknown names fail cleanly
Section titled “Unknown names fail cleanly”$ dig @192.168.2.241 example.com A +noall +comments | grep status:;; ->>HEADER<<- opcode: QUERY, status: SERVFAIL, id: 24601With no-resolv and no server=, non-local names return SERVFAIL. That is expected, not broken DNS. Add an explicit server= when forwarding is required.
Firewall
Section titled “Firewall”$ firewall-cmd --list-servicescockpit dhcpv6-client dns sshThe dns service opens both 53/udp and 53/tcp. The Server environment does not include it by default.
Common traps
Section titled “Common traps”- Omitting
bind-interfaces: dnsmasq may fight NetworkManager’s local resolver for port 53; - Forgetting
local-ttl: downstream caches can never keep your local records; - Testing via 127.0.0.1: outside
listen-addressqueries are refused, which looks like “the service is down”; - Expecting per-host control from
address=: it is domain-wide; usehost-record=for exact entries.
Practice: add one exact record
Section titled “Practice: add one exact record”sudo tee /etc/dnsmasq.d/extra.conf >/dev/null <<'EOF'host-record=db.lab.test,192.168.2.250EOFsudo systemctl restart dnsmasqdig @192.168.2.241 db.lab.test A +noall +answerdig @192.168.2.241 other.lab.test A +noall +answerChecks:
db.lab.testanswers 192.168.2.250;other.lab.teststill matches the wildcard;- Both TTLs follow
local-ttl; - Removing
extra.confand restarting restores the previous behaviour.
常见问题
dnsmasq or BIND?
dnsmasq suits small setups with simple DNS+DHCP; BIND is for zone transfers, DNSSEC signing and complex views.
Can it do DHCP too?
Yes — dhcp-range shares the same config, and leases can be registered in DNS automatically.
Any SELinux work needed?
Not for port 53; a non-standard port needs semanage port -a to label it.
Next steps
Section titled “Next steps”- Network troubleshooting: /en/network-troubleshoot/
- Resolver configuration: /en/systemd-resolved/
- Firewall: /en/firewalld-zones/