Candid photograph of a Linux server terminal with a soft olive-green glow against a dark slate background, conveying a calm technical atmosphere.

Step-by-step guides for system administrators — covering command-line basics, web server setup, and preparation material for technical interviews.

Browse Tutorials

Building a Local DNS Cache Resolver with Unbound on Fedora

Unbound is a compact recursive resolver that remembers the answers it has already fetched. Point your machines at it and repeat lookups are served from memory in under a millisecond, while first-time questions are forwarded and validated on your behalf. Fedora packages it cleanly, which makes it a sensible addition to any workstation or small server.

That speed matters more in Australia than in many other places. Authoritative servers for .com, .net and .org sit offshore, and traffic reaches them through submarine cables such as the Australia–Singapore Cable and the Southern Cross network, so a cold lookup can cost 150 milliseconds or far more. A local cache turns that recurring round trip into a local lookup, and keeps working during the brief outages that happen when a cable or an upstream provider misbehaves.

This guide walks through installing Unbound, sending queries to forwarders, restricting access to your own network, and enabling DNSSEC validation. It also covers the details that catch people out on Fedora, where systemd-resolved may already own port 53 and NetworkManager may overwrite your resolver settings.

You will need sudo access on a Fedora 40 or newer machine, a static address for any server, and a working backup plan for /etc/resolv.conf. Before changing anything, check whether systemd-resolved is active with resolvectl status and note what it reports, because that is the usual reason an Unbound service refuses to bind.

What a caching resolver actually does

A resolver answers three kinds of question: what is the address for this name, how do I reverse this address, and which mail servers handle this domain. To answer the first one, Unbound either walks the hierarchy from the root down to an authoritative server, or asks a forwarder to do that work on its behalf. Both routes end with an answer stored in cache and tagged with its time to live.

The cache is the useful part for everyday use. A query for a popular Australian bank, government portal or streaming service gets answered from RAM after the first request, and entries can be refreshed in the background before they expire. Unbound also performs DNSSEC validation, so a forged answer gets dropped rather than returned to your browser.

If you want the wider picture before diving in, the Linux and Unix tutorials on this site cover related ground such as firewall management and service hardening.

Installing Unbound and the root hints on Fedora

Install the resolver and the digging tools together:

sudo dnf install unbound bind-utils

Then start it and confirm it is enabled at boot:

sudo systemctl enable --now unbound
sudo systemctl status unbound

Unbound reads /etc/unbound/unbound.conf and everything under /etc/unbound/conf.d, so keep your own settings in a separate file such as /etc/unbound/conf.d/local.conf rather than editing the packaged one. If /var/lib/unbound/root.hints is missing, install the bind package and copy the hints it ships: sudo dnf install bind, then sudo cp /usr/share/dns/root.hints /var/lib/unbound/root.hints.

Before starting the service, check that nothing else holds port 53:

sudo ss -lunp | grep ':53'

If systemd-resolved appears there, decide which resolver owns the machine. Many administrators disable it with sudo systemctl disable --now systemd-resolved, then replace the /etc/resolv.conf symlink with a plain file containing nameserver 127.0.0.1 and options edns0 trust-ad. Keep a copy of the original file, because NetworkManager tends to rewrite resolv.conf whenever a connection changes.

Pointing Unbound at forwarders

A forwarder gives Unbound someone to ask, which saves the resolver from walking the root hierarchy itself. Australian providers are the sensible first choice because they answer over peering paths that are already warm for your line:

forward-zone:
    name: "."
    forward-addr: 203.0.113.53@53
    forward-no-cache: no

Replace that address with the resolver your broadband provider hands out, or with a public one such as 1.1.1.1 or 9.9.9.9, both of which maintain points of presence in Australia. Measure rather than guess: run dig @1.1.1.1 example.com and dig @9.9.9.9 example.com a few times during the arvo when traffic is busiest, and compare the query times.

One Australian quirk is worth remembering. NBN routers often hand out provider resolvers on 10.x.x.x addresses that are only routable inside your own network. Those addresses work perfectly on a home server but fail silently on a VPS in Melbourne or Singapore, so label your config accordingly.

While you tune these settings, keeping notes matters. Administrators who live in Emacs can hold the working configuration and query results in session variables in Emacs, which saves a lot of scrolling through terminal history.

Limiting access to your own networks

An open resolver on a public address is an abuse magnet, so bind Unbound to the interfaces you need and allow only your own subnets. The following example serves loopback plus a typical home LAN:

server:
    interface: 127.0.0.1
    interface: ::1
    port: 53
    do-ip4: yes
    do-ip6: yes
    access-control: 127.0.0.0/8 allow
    access-control: ::1 allow
    access-control: 192.168.1.0/24 allow
    hide-identity: yes
    hide-version: yes
    qname-minimisation: yes
    aggressive-nsec: yes

If you serve clients over IPv6, remember to add the matching prefix rules, and if you use a non-standard NBN gateway address such as 192.168.10.0/24, adjust the list to match.

Fedora ships firewalld by default, so open the resolver port for local clients:

sudo firewall-cmd --permanent --add-service=dns
sudo firewall-cmd --reload

The dns service covers both UDP and TCP on port 53, which is what you want for large responses and zone transfers.

Turning on DNSSEC validation for .au and beyond

DNSSEC lets a resolver prove that an answer was signed by the domain owner. Australian domains benefit directly, since the .au registry publishes signed delegations, and the same validation protects every other top-level domain in the chain.

The packaged Unbound configuration already points at a root key file. Make sure it exists and is current:

sudo unbound-anchor
sudo ls -l /var/lib/unbound/root.key

Keep auto-trust-anchor-file: "/var/lib/unbound/root.key" in your server block so the trust anchor refreshes on its own schedule. A resolver that validates but holds a stale anchor can fail every lookup, and that failure often looks like a network problem rather than a trust problem.

Two settings are useful on links with long latency: prefetch: yes refreshes popular records before they expire, and serve-expired: yes returns stale answers during a brief upstream outage instead of timing out. Australia has plenty of situations where the second option earns its keep.

How DNS supports mail and other services

Resolver work goes far beyond web browsing. Mail servers look up MX records, and delivery agents check the address records for the receiving domain. If you are also building mail infrastructure, the same DNS questions come up when you set up a mail server with Postfix, where a reliable local resolver avoids duplicated lookups across every queued message.

Container platforms and orchestrators add another wrinkle: they resolve service names internally, and a misconfigured resolver on the host can break name lookups for containers that have their own network namespace. Test from the host first, then from inside the container, and you will know which layer is at fault.

For reverse lookups on local subnets, add a private-domain zone so Unbound answers locally rather than sending those queries upstream:

server:
    private-domain: "home.example.au"

Checking queries and making the resolver permanent

Dig is the quickest way to confirm the resolver is doing its job:

dig @127.0.0.1 example.com
dig @127.0.0.1 -t MX example.com
dig @127.0.0.1 example.com +noall +answer

The answer section should show a low TTL the first time and a higher one afterwards, since the cached record is younger. To see the cache directly and clear a single zone while testing, generate the control certificates with sudo unbound-control-setup, then use unbound-control stats and unbound-control flush_zone example.com.

Logs come through the journal, and they are worth watching while you tune things:

sudo journalctl -u unbound -f

If Unbound starts but answers nothing, check SELinux denials with sudo ausearch -m avc -ts recent, and confirm the service can read its own files under /var/lib/unbound.

Make the setup survive a reboot by adding unbound to the enabled services with sudo systemctl enable unbound and confirming that /etc/resolv.conf still points at 127.0.0.1 after a NetworkManager reconnect. Your next concrete step is to add your LAN subnet to the access-control list, run sudo systemctl restart unbound, and confirm the change with dig @127.0.0.1 example.com.