NetworkManager dnsmasq#

Use NetworkManager’s integrated dnsmasq.

In /etc/NetworkManager/NetworkManager.conf enable dnsmasq by setting dns=dnsmasq, e.g.

[main]
plugins=ifupdown,keyfile
dns=dnsmasq

Disable the stub resolver of systemd-resolvd:

cat <<'EOF' > /etc/systemd/resolved.conf
[Resolve]
DNSStubListener=no
EOF

rm /etc/resolv.conf
systemctl restart systemd-resolved.service
systemctl restart NetworkManager
cat /etc/resolv.conf
# "Generated by NetworkManager"

Example config files:

# use local hosts file
cat <<'EOF' > /etc/NetworkManager/dnsmasq.d/hosts.conf
addn-hosts=/etc/hosts
EOF

# set localhost on port 1053 for the domain "foo"
cat <<'EOF' > /etc/NetworkManager/dnsmasq.d/foo-server.conf
server=/*.foo/127.0.0.1#1053
EOF

systemctl reload NetworkManager

Debugging#

List processes listening on UDP

netstat -panu

Notes#

  • systemd-resolvd symlinks /etc/resolv.conf to /run/systemd/resolve/resolv.conf

  • NetworkManager writes /etc/resolv.conf as soon as the symlink is removed