Change DNS on Fedora

Hi!
OS Fedora 39
I have a desktop computer connected to the router via a wired connection. On Fedora, the DNS is set to the router’s IP. How can I change the DNS to a different IP from the command line? The resolv.conf file gets overwritten upon restart.

I tried to change to change DNS in
/etc/systemd/resolved.conf
Than, i write in file /etc/NetworkManager/conf.d/10-dns-systemd-resolved.conf

[main]
   dns=none

but that didn’t help.
Thanks

Edit your network connection settings:

  • GNOME Settings > Network > Wired > :gear: > IPv4/IPv6 > DNS > Automatic > Off > …

Note that this statement is incorrect.

$ ls -l /etc/resolv.conf
lrwxrwxrwx. 1 root root 39 Apr 13  2023 /etc/resolv.conf -> ../run/systemd/resolve/stub-resolv.conf

The file that it points to gets created with each boot/reboot, but /etc/resolv.conf is not changed.
If you were to remove that symlink and create your own file there it would remain unchanged in the future.

The above suggestion that you marked as the solution is the better choice though.

1 Like

as the file says
cat /etc/systemd/resolved.conf

edit this file to override anyone of the above or create dropins into resolved.conf.d

man resolved.conf.d for more info

regards peter