Overriding ISP Provided DNS Server

Overriding ISP Provided DNS Server in Ubuntu 12.04If you’re on Ubuntu 12.04, you’ll notice how DNS severs are no longer set in /etc/resolv.conf, rather /etc/resolv.conf points to 127.0.0.1, and NetworkManager runs an instance of dnsmasq that dynamically changes your DNS server based on the settings obtained from your network. It handles cases where you switch networks well.

Except if you live in a country where sites are blocked via the ISP’s DNS … and would rather override the ISP’s suggested DNS server with Google’s free DNS server at 8.8.8.8.

Well there’s a good article on how Ubuntu 12.04’s DNS resolving works at http://www.stgraber.org/2012/02/24/dns-in-ubuntu-12-04/.

In short, I managed to override it on my desktop and laptop by appending “nameserver 8.8.8.8” to /etc/resolvconf/resolv.conf.d/head.

For servers, where network manager is not in use, and you use static IP adressing, the DNS server can now go into the /etc/network/interfaces file … under the iface as “dns-nameservers”, as described here: http://www.jansipke.nl/ubuntu-12-04-network-configuration/.

Update: An alternative way to force a fixed DNS server is to hack dhclient … as described here: http://www.liberiangeek.net/2012/05/setup-static-dns-servers-in-ubuntu-12-04-precise-pangolin/ … but this only works for DNS supplied via DHCP.

UPDATE 2012-10-28: … this works until you are on a “captive portal” wifi network that uses “DNS Poisoning” to get you to the acces control page. In those situations, you will need to undo this and use the DNS provided by DHCP, at least until authenticated.

#ubuntu   #dns


LINK:

DNS in Ubuntu 12.04 | Stéphane Graber’s website


Comments (3):

  • 2014-05-08 02:38:02+0800 Sem Brignoli But how did u append the # Dns to the /etc/resolvconf/resolv.conf.d/head. if the files quote that all manual changes will be overwritten?
  • 2014-05-12 12:33:39+0800 shahada abubakar +Sem Brignoli The “head” and “base” files form a template that are merged together with DNS server addresses into the actual /etc/resolv.conf file. The message about not editing by hand in the “head” file is intended to be read after its been merged into /etc/resolv.conf. 😎 Did you have any problem with your changes disappearing from the “head” file?
  • 2014-05-12 12:36:11+0800 Sem Brignoli Mm.. Not yet… I’m trying to get a new more customizable router to make it easier and faster.. If I can I will keep trying.. Thanks thought

This post was originally published publicly on Google+ at 2012-10-09 02:48:17+0800

You may also like...