Skip to content
Search AlmaLinux

    Browse this documentation

    AlmaLinux 10: a LAN DNS server with dnsmasq

    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.

    /etc/dnsmasq.d/lab.conf
    listen-address=192.168.2.241
    bind-interfaces
    address=/lab.test/192.168.2.241
    local-ttl=60
    no-resolv
    log-queries
    • listen-address + bind-interfaces: serve only on that address, avoiding port 53 conflicts;
    • address=/lab.test/…: a wildcard — every *.lab.test resolves to the same address;
    • local-ttl=60: TTL for those local records (the default is 0, see below);
    • no-resolv: ignore /etc/resolv.conf upstreams.
    $ ss -lunp | grep ':53 ' | head -1
    UNCONN 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.

    $ dig @192.168.2.241 web.lab.test A +noall +answer
    web.lab.test. 60 IN A 192.168.2.241

    Without local-ttl, the same record carries TTL 0:

    web.lab.test. 0 IN A 192.168.2.241

    TTL 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.

    $ dig @192.168.2.241 example.com A +noall +comments | grep status:
    ;; ->>HEADER<<- opcode: QUERY, status: SERVFAIL, id: 24601

    With 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-cmd --list-services
    cockpit dhcpv6-client dns ssh

    The dns service opens both 53/udp and 53/tcp. The Server environment does not include it by default.

    • 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-address queries are refused, which looks like “the service is down”;
    • Expecting per-host control from address=: it is domain-wide; use host-record= for exact entries.
    Terminal window
    sudo tee /etc/dnsmasq.d/extra.conf >/dev/null <<'EOF'
    host-record=db.lab.test,192.168.2.250
    EOF
    sudo systemctl restart dnsmasq
    dig @192.168.2.241 db.lab.test A +noall +answer
    dig @192.168.2.241 other.lab.test A +noall +answer

    Checks:

    1. db.lab.test answers 192.168.2.250;
    2. other.lab.test still matches the wildcard;
    3. Both TTLs follow local-ttl;
    4. Removing extra.conf and 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.