What does a DNS resolver do?
Every time software on your server connects to a host name, such as a package mirror, an API or a database replica, it first needs the address. It asks a resolver. A recursive resolver does the full work: if the answer is not in its cache, it asks the root name servers where to find .com, asks the .com servers where to find example.com, asks those authoritative servers for the record, and returns the result. It then caches the answer for the record's TTL, so repeated lookups take microseconds.
What kinds of resolver are there?
| Type | Job | Example |
|---|---|---|
| Stub resolver | Library in each program that forwards queries | glibc, reading /etc/resolv.conf |
| Local caching forwarder | Caches answers on the machine, forwards misses | systemd-resolved, dnsmasq |
| Recursive resolver | Walks the DNS tree itself | Unbound, BIND, Knot Resolver |
| Public resolver | Recursive service open to everyone | 1.1.1.1, 8.8.8.8, 9.9.9.9 |
A resolver is the asking side. The answering side is the authoritative server run by a domain's DNS provider.
Which resolver does my server use?
cat /etc/resolv.conf resolvectl status | sed -n '1,25p' getent hosts deb.debian.org
On Ubuntu, /etc/resolv.conf usually points at 127.0.0.53, the local systemd-resolved stub, and resolvectl status shows the upstream servers it forwards to. On Debian and Enterprise Linux the file often lists upstream servers directly. getent hosts performs a lookup the same way applications do, including /etc/hosts, which makes it better than dig for debugging what an app actually sees.
Why run my own resolver on a server?
- Speed: busy servers that resolve many names, such as mail servers checking blocklists, crawlers and API clients, benefit from a local cache.
- Reliability: no dependence on one upstream; a full recursive resolver asks authoritative servers directly.
- Privacy and accuracy: queries are not shared with a third party, and DNSSEC validation happens on your machine.
- Mail filtering: many DNS blocklists refuse queries from big public resolvers, so a mail server needs its own (Email server).
How do I set up Unbound as a local resolver?
apt install -y unbound # dnf install -y unbound on Enterprise Linux
cat > /etc/unbound/unbound.conf.d/local.conf <<'EOF'
server:
interface: 127.0.0.1
access-control: 127.0.0.0/8 allow
prefetch: yes
cache-min-ttl: 60
qname-minimisation: yes
EOF
unbound-checkconf && systemctl restart unbound
dig @127.0.0.1 example.org +dnssec | grep -E 'flags|status'
Then point the system at it: on Ubuntu, set DNS=127.0.0.1 in /etc/systemd/resolved.conf and restart systemd-resolved, or replace the resolv.conf link with a file containing nameserver 127.0.0.1. The ad flag in the dig output shows DNSSEC validation worked. Listening only on loopback keeps the resolver private; an open resolver on a public address gets abused for amplification attacks.
Can VMs and containers use it too?
Yes. Add the bridge address as an interface and allow the guest subnet, for example interface: 10.10.0.1 and access-control: 10.10.0.0/24 allow, then hand that address to guests via DHCP. One cache for the whole box saves lookups and keeps behavior consistent. A small machine like E1 runs Unbound with plenty to spare; even very busy resolvers need only a few hundred megabytes of RAM for cache.
Should I enable DNS over TLS to my upstream?
If you forward to a public resolver instead of resolving recursively, encrypting that hop keeps queries private on the wire. systemd-resolved supports it with DNSOverTLS=yes in resolved.conf, and Unbound with a forward-zone that sets forward-tls-upstream: yes and the provider's TLS name. A full recursive resolver talks to authoritative servers, which mostly do not support encryption yet, so the choice is between forwarding privately to one trusted provider and resolving directly yourself. Both are reasonable; pick one and monitor it.
What are common resolver problems?
Slow first connections often mean a dead upstream server listed first in resolv.conf; resolvers try it, time out and only then move on. Intermittent failures for one domain usually come from its authoritative side or a DNSSEC mistake there, which dig +cd (checking disabled) helps confirm. And if a name resolves on your laptop but not on the server, compare resolvers before suspecting anything else. The nslookup command and The dig command cover the tools.
Machines That Host Resolvers and Mail
| Server | Processor | Cores / threads | Memory | Storage | Network | Per month | Smallest order |
|---|---|---|---|---|---|---|---|
| E1 | Intel Xeon E3-1240 v3 | 4 / 8 | 16 GB DDR3 | 2x 240 GB SSD | 2x 1 Gbps | $30.52 | $91.56 (3 months) |
| E2 | Intel Xeon E3-1270 v3 | 4 / 8 | 32 GB DDR3 | 1x 480 GB SSD | 2x 1 Gbps | $38.32 | $114.96 (3 months) |
| S1 | Intel Xeon E-2276G | 6 / 12 | 64 GB DDR4 | 1x 1 TB NVMe | 2x 10 Gbps | $53.32 | $53.32 (1 month) |
| S3 | Intel Xeon E-2356G | 6 / 12 | 64 GB DDR4 | 2x 1 TB NVMe | 2x 10 Gbps | $80.38 | $80.38 (1 month) |
Keep Reading
DNS provider
The service that hosts your domain's DNS records, how it differs from the registrar, and how to choose and set one up for a server.
OpenDNS propagation
Why a DNS change takes time to reach everyone, how TTLs and caches decide the delay, and how to plan a server move with almost no wait.
OpenThe nslookup command
Look up DNS records with nslookup on any system, use its interactive mode, switch servers and record types, and know when dig is better.
OpenEmail server
The parts of a mail server, from SMTP and IMAP to spam filtering, and the DNS and delivery details that decide whether mail arrives.
OpenFAQ
Quick Answers
A resolver looks up answers for clients. An authoritative DNS server holds and serves the records for a domain.
On Ubuntu, systemd-resolved runs a local stub on that address and forwards queries to upstream servers.
It helps on mail servers, crawlers and busy API clients, and for DNSSEC validation. Small sites do fine with defaults.
No. Open resolvers are abused for amplification attacks. Listen on loopback or private networks only.
Use getent hosts name, which follows the same order as applications, including /etc/hosts.