How do I configure an Ubuntu 20.04 system so it overrides the default DNS?
It seems that by default there is a global and per-link DNS setting.
I tried a couple of things that did not work:
/etc/systemd/resolved.confwith the DNS Servers
/etc/systemd/network/enp0s3.confwith the DNS servers configured
- Removed all DNS related parameters from the DHCP request by editing
All these changes (and the combinations) result in the DNS servers being prepended to the list of global DNS servers.
Most 'solutions' are to either install
resolvconf or replace the
/etc/resolv.conf symbolic link with a file and set the DNS servers there. Both of these seem like a workaround.
I would like to use the existing tooling (
systemd-resolved) to override the DNS Servers.
As suggested by @xenoid in the comments:
Setting the DNS for the interface through the GUI resulted in a file
/etc/NetworkManager/system-connections/enp0s3.nmconnection that contains the correct DNS servers, the output of
resolvectl status includes the correct DNS servers, this however is not what I had in mind.
I am looking for a solution that does the configuration using
systemd-resolved, which is possible from what I can find, but it is unclear how. Since this requires a GUI installation.