30
October
2023
11:11

Configuring a systemd-resolved caching DNS server

30 October 2023 11:11

To speed up DNS name resolution, a local caching server is used. The difference (speedup) is 50-150 milliseconds per request for cached data. How to enable the service systemd-resolved in Linix Mint or Ubuntu?

  1. Installing DNS resolver for SystemD in Ubuntu/Linux Mint:
sudo apt install libnss-resolve
  1. Setting up the ResolveD service
sudo nano /etc/systemd/resolved.conf

Remove comments next to lines

[Resolve]
DNS=192.168.1.1
FallbackDNS=77.88.8.1
Domains=~.
DNSStubListener=yes # listens 127.0.0.53:53

where 192.168.1.1 - replace with the IP address of the main router on the local network,
instead of 77.88.8.1 you can specify any public DNS server,
the DNSStubListener option is required to use the additional address 127.0.0.53 for listening (see point 5 below).

  1. Start and enable the ResolvedD service for DNS resolution
sudo systemctl start systemd-resolved
sudo systemctl enable systemd-resolved
  1. Checking status
resolvectl status
  1. If you use the NetworkManager graphical tool to manage your network, you need to specify the following in the "Network Settings" (gear icon) IPv4 settings:
IPv4 -> DNS Server
127.0.0.53
  1. Edit file /etc/resolv.conf

    sudo nano /etc/resolv.conf

Add:

nameserver 127.0.0.53
  1. Using the console utility resolvectl

Utility resolvectl can be used for service management systemd-resolved.service and for domain name resolution. The most common command of this utility is query HOST_NAME for name resolution, both IPv4 and IPv6. When used with the -t TYPE switch, where TYPE is a designation of the type of DNS record, for example, TXT records (certificates) versus regular A, AAAA records. A detailed description of the resolvectl command switches is available in the man resolvectl help pages.

Examples of use:

resolvectl query ya.ru
resolvectl query google.com -t AAAA

7.1 Displaying the service status resolved

systemctl is-active systemd-resolved

Answer: "active" - the service is running.

7.2. Displaying statistics of calls to the local DNS cache

resolvectl statistics

Answer:

DNSSEC supported by current servers: no

Transactions
Current Transactions: 0
Total Transactions: 7606

Cache
Current Cache Size: 136
          Cache Hits: 2139
        Cache Misses: 5493

DNSSEC Verdicts
              Secure: 0
            Insecure: 0
               Bogus: 0
       Indeterminate: 0

7.3. Clearing the DNS cache using the resolvectl command in Linux:

resolvectl flush-caches

Sources:
https://zevilz.dev/posts/496/
systemd-resolve-command-not-found
*systemd-resolved at wiki.ubuntuusers.de


Last modified: 09/01/2026
(line "Domains=~." and the line following it,
changed paragraphs 5 and 6).



Related publications