Is it possible to set the global DNS server in a snap?
I know that by using systemd-resolved D-BUS API, it would work to set a DNS server for a specific link (tbh, I haven’t tried), according the the comment in
# Allow access to the safe members of the systemd-resolved D-Bus API:
# This API may be used directly over the D-Bus system bus or it may be used
# indirectly via the nss-resolve plugin:
Another thought is to use
system-files interface and write the DNS config file to
Indeed, network-control does not expose a way to permanently change DNS configuration. AFAIU the SetLinkDNS is only temporary. Looking at the docs at https://www.freedesktop.org/software/systemd/man/org.freedesktop.resolve1.html the intention is for it to be called by network management software. probably the likes of systemd-networkd/NeworkManager once they get the DNS servers via DHCP.
I think that maybe you could probably produce a config for netplan which sets the DNS servers in the system. This is allowed by using
However, I don’t think there’s a way to set
DNS=... in resolved.conf without using
system-files. Though, the net effect is probably identical if you just specify the same list of DNS servers in
nameservers for each interface.