I've struggled with dns myself and have posted a question and solution to it, which lists some of the ways you can change dns settings. Basically, there are two ways - either edit any of 3 files in /etc/resolvconf/resolv.conf.d/
or edit /etc/dhcp/dhclient.conf
. I personally prefer the first one.
Bellow are some of the methods i apply to my ubuntu and linux mint systems. Use at your discression.
/etc/dhcp/dhclient.conf
I will start with this since others have covered already resolv.conf files. What you see bellow is portion of this file. Look at line 18, which says prepent name server
. It will add your specified dns to the settings, no matter what connection you use.
1 # Configuration file for /sbin/dhclient, which is included in
Debian's
2 # dhcp3-client package.
3 #
4 # This is a sample configuration file for dhclient. See dhclient.conf's
5 # man page for more information about the syntax of this file
6 # and a more comprehensive list of the parameters understood by
7 # dhclient.
8 #
9 # Normally, if the DHCP server provides reasonable information and does
10 # not leave anything out (like the domain name, for example), then
11 # few changes must be made to this file, if any.
12 #
13 option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;
14 #send host-name "andare.fugue.com";
15 send host-name = gethostname();
16 #send dhcp-client-identifier 1:0:a0:24:ab:fb:9c;
17 #send dhcp-lease-time 3600;
18 #supersede domain-name "fugue.com home.vix.com";
19 #prepend domain-name-servers 127.0.0.1;
20 prepend domain-name-servers 208.67.220.220;
21 request subnet-mask, broadcast-address, time-offset, routers,
22 domain-name, domain-name-servers, domain-search, host-name,
23 dhcp6.name-servers, dhcp6.domain-search,
24 netbios-name-servers, netbios-scope, interface-mtu,
25 rfc3442-classless-static-routes, ntp-servers,
26 dhcp6.fqdn, dhcp6.sntp-servers;
27 #require subnet-mask, domain-name-servers;
28 #timeout 60;
29 #retry 60;
30 #reboot 10;
31 #select-timeout 5;
32 #initial-interval 2;
33 #script "/etc/dhcp3/dhclient-script";
34 #media "-link0 -link1 -link2", "link0 link1";
35 #reject 192.33.137.209;
36 #alias {
37 # interface "eth0";
/etc/resolvconf/resolv.conf.d/
The text from either of 3 will be added to /etc/resolv.conf
, so I don't think it matters which one you choose. I'd use tail
, personally. Simply open it with any text editor and add nameserver 8.8.8.8
, where 8.8.8.8 is google's public dns but you can use whatever dns you like.
A small tip
In /etc/Network-Manager/Network-Manager.conf
I suggest you comment out dns=dnsmasq
line, which is a plugin for network manager, which goes automatically to the nearest/easiest to reach dns, which might not be what you want, if you want to by pass the network's dns, and use your own.
Side note: The fact that resolv.conf gets rewritten is actually normal - it does so upon every new connection on my machine as well. While I can't answer why, my guess is that NetworkManager gets dhcp lease from the local connection, and uses that local connection's settings, dns, and whatever else, so resolv.conf needs to be adapted to that.