Tag: systemd-resolved

Change configuration of `systemd-resolved`

Change configuration of systemd-resolved

If the configuration in /etc/resolv.conf as below

...
nameserver=127.0.0.53
...

Most likely the DNS configuration is controlled by systemd-resolved service.

To confirm, run following command

lsof -i :53

or

ls -ld /etc/resolv.conf

Change configuration

Change /etc/resolv.conf

If change /etc/resolv.conf directly, the file will be overwritten by systemd-resolved again when next reboot, because the file /etc/resolv.conf is a link as below.

lrwxrwxrwx 1 root root 39 Oct  5  2021 /etc/resolv.conf -> ../run/systemd/resolve/stub-resolv.conf

If recreate the file /etc/resolv.conf, then it could be overwritten by systemd-resolved when run service reconfiguration.

Change /etc/systemd/resolved.conf

The configuration of systemd-resolved is in /etc/systemd/resolved.conf, it can be changed as below.

DNS=<DNS_Server>
Domains=<Doman_name>
....

References

Changing DNS with systemd-resolved