(solved) Change DNS setting

Started by sunrat, 2017/08/29, 16:25:12

Previous topic - Next topic

sunrat

I am trying to set a different DNS server to the default one. I'm connecting via wifi to a modem/router which doesn't allow DNS server setting to be changed. Have tried a few things to no avail:
- nameserver 208.67.222.222 in resolv.conf  This always gets overwritten on restart but I'm not sure by what. resolvconf is not installed
-     nameserver 208.67.222.222 in /etc/network/interfaces.
- prepend domain-name-servers 208.67.222.222 208.67.220.220 in dhclient.conf
- DNS=208.67.222.222 in /etc/systemd/resolved.conf

network-manager is still installed but unused as wifi config is set up in interfaces file. Could this be what is overriding other configs?

pjnsmb

have a look at the chattr command



chattr +i /etc/resolv.conf (stop it being overwritten)
chattr -i /etc/resolv.conf   (cancel)


look at man chattr



regards
pjnsmb

sunrat

Thanks pjnsmb. I did find that workaround in searching and will try it as a last resort. I'd still like to know what is overwriting interfaces file.

melmarker

using chattr in that case is the same as killing your wife because she is a bad cook - better would be in case a) if using resolvconf with n-m setting up the networkmanager/resolvconf right - same as without resolvconf. b) help her learn cooking.
Those who would give up essential Liberty, to purchase a little temporary Safety, deserve neither Liberty nor Safety. (Benjamin Franklin, November 11, 1755)
Never attribute to malice that which can be adequately explained by stupidity. (Hanlons razor)

piper

Not to say to use google dns, but, a good example, guideline

https://developers.google.com/speed/public-dns/docs/using
I have a Lucky Rabbit:    "Svoot" ..... (It's Swedish)

I am MAGA

sunrat

Thanks for the replies but I'm not using network-manager or resolvconf. This is a desktop system always using the same wifi and connection is set in /etc/network/interfaces. I'm trying to use OpenDNS and it's not configurable in the router.
Would removing/purging network-manager help or could this have unintended consequences?
I don't have a wife either so can't kill her. :D

melmarker

Please post the status of network-manager - and yes, one can purge n-m (ceni and ifupdown and wpa-supplicant are sufficient)
Those who would give up essential Liberty, to purchase a little temporary Safety, deserve neither Liberty nor Safety. (Benjamin Franklin, November 11, 1755)
Never attribute to malice that which can be adequately explained by stupidity. (Hanlons razor)

sunrat

roger@siduction-brain:~$ nmcli d
Error: NetworkManager is not running.


roger@siduction-brain:~$ systemctl list-units |grep network
networking.service                                                                                         loaded active exited    Raise network interfaces                                                         
vnstat.service                                                                                             loaded active running   vnStat network traffic monitor                                                   
network-online.target                                                                                      loaded active active    Network is Online                                                               
network.target                                                                                    loaded active active    Network
 

piper

Does this work for you with the problem of 'overwritten on restart' , I don't use sudo, so ...

nano /etc/dhcp/dhclient.conf

Add the following line to the document before the 'require subnet-mask' command

supersede domain-name-servers 208.67.222.222,208.67.220.220;

save and exit

ifdown eth0 && sudo ifup eth0

You 'might'  be required to change eth0 to your own network device's name if it uses 'Predictable Network Interface Names'.
I have a Lucky Rabbit:    "Svoot" ..... (It's Swedish)

I am MAGA

sunrat

I tried "prepend" in that file to no avail. Will try that tonight (in about 8 hours here).

I'm using dig to show the DNS used, hopefully that is correct:
$ dig google.com |grep SERVER
;; SERVER: 192.168.0.1#53(192.168.0.1)

sunrat

Thanks piper, looks like the "supersede" line worked.  :)

dig google.com |grep SERVER
;; SERVER: 208.67.222.222#53(208.67.222.222)

piper

Good deal sunrat   :)
I have a Lucky Rabbit:    "Svoot" ..... (It's Swedish)

I am MAGA