Changing DNS settings

How can DNS setting be changed across all networks? it is easy to change on a per wireless network basis using Gnome Network Manager on any desktop environment, but DNS has to be set for every wireless network separately.

Wouldn’t it be easiest to change it in your router settings?

5 Likes

Change DNS in router instead!

Edit:

Too late!

1 Like

Travel a lot and ISP router cannot change DNS anyways. Could install IPFire or Pi-hole or install a Tomato router behind ISP router or something (and have done all in the past) but just want to keep this simple. Am looking to just change DNS on a single machine for all wireless networks at once (one, and only one, thing Windows does better than Linux.)

Windows better than Linux … :wink: .

It should ( :pray:) suffice to modify your /etc/resolv.conf as described in the ArchWiki here and here for instance.

So …

  1. Add up to three nameserver(s) to /etc/resolv.conf, e. g.
    sudo sh -c 'printf "nameserver 208.67.222.222\nnameserver 208.67.220.220\n" > /etc/resolv.conf'

  2. Optionally protect your /etc/resolv.conf from being modified by setting the immutable (write-protection) attribute
    sudo chattr +i /etc/resolv.conf

  • Check which servers are used with nslookup or dig, e. g.
    nslookup endeavouros.com
2 Likes

On Debian resolv.conf is a symlink to /etc/resolvconf/run/resolv.conf

If this is the case I don’t think the above would work. Will check if this is the case on Arch and post again after checking.

Don’t do that.

Do this instead: https://wiki.archlinux.org/index.php/NetworkManager#Unmanaged_/etc/resolv.conf

@schnappi: When running systemd-resolved, /etc/resolv.conf is or should be a symlink to /run/systemd/resolve/stub-resolv.conf on Arch systems.
Everything is described in Arch wiki, here and here.

3 Likes

You’re right, this should be the preferred way of preventing NetworkManager from changing the configuration, -but- this will only stop NetworkManager from modifying /etc/resolv.conf.

I admit the chance being slim but various other processes and applications, for instance dhcpcd and netctl, could still overwrite /etc/resolv.conf. That’s why I personally think write protecting /etc/resolv.conf is still a viable solution if you want to prevent it from being modified by anything.
For me it’s so much easier to edit resolv.conf manually, then write protect with the +i flag and undo with the -i flag if need be.

Isn’t it nice to have options? :grinning: