Table of Contents

Using systemd-resolved

Configure NetworkManager

Edit the /etc/NetworkManager/NetworkManager.conf file, and set the following entry in the [main] section:

dns=systemd-resolved

Reload the NetworkManager service:

# systemctl reload NetworkManager

Force adjusting of /etc/resolv.conf

  netconfig update -f

Verification steps

Verify that the nameserver entry in the /etc/resolv.conf file refers to 127.0.0.53:

# cat /etc/resolv.conf
nameserver 127.0.0.53

Verify that the systemd-resolved service listens on port 53 on the local IP address 127.0.0.53:

# netstat -tulpn | grep "127.0.0.53:53"
tcp   0   0 127.0.0.53:53   0.0.0.0:*   LISTEN   1050/systemd-resolv
udp   0   0 127.0.0.53:53   0.0.0.0:*            1050/systemd-resolv

1. Wireguard

https://www.reddit.com/r/WireGuard/comments/1foqw8w/wireguard_issues_relating_to_dns_after_upgrade_to/ https://www.procustodibus.com/blog/2022/03/wireguard-dns-config-for-systemd/

Remove DNS entry from wireguard conf. Not using WG dns though

2. Add DNS Entries

3. Troubleshooting

Some domain cannot be resolved (e.g., google.com but bing.com works). After updating system, may be relink the resolve file:

sudo ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf

Check which route the DNS query goes:

  ip route get 1.1.1.1
  
  dig google.com @1.1.1.1
  resolvectl query google.com

Resources