How to use a custom DNS server on Ubuntu desktop

Last updated on December 11, 2012 by Dan Nanni

In Linux, DNS servers are specified in /etc/resolv.conf. However, a proper way to configure custom DNS settings on Ubuntu desktop is not manually modifying /etc/resolv.conf, but using a separate GUI-based network management program which controls the content of /etc/resolv.conf.

The default such program used by Ubuntu desktop is called Network Manager, which is responsible for configuring network settings (e.g., IP address, DNS servers, proxy settings, etc). If you directly modify DNS settings in /etc/resolv.conf without going through NetworkManager, such DNS settings may be ignored by GUI applications (e.g., Firefox, Chrome, etc), or be later overwritten by Networ kManager.

Another caveat to take care of is the fact that Ubuntu Desktop 12.04 and higher comes with dnsmasq installed and enabled, which essentially turns your Ubuntu Desktop into its own caching DNS server. So your Ubuntu desktop is set to use 127.0.0.1 as its default DNS server.

Given these circumstances, if you would like to use a custom DNS server on Ubuntu desktop, you need to turn off dnsmasq first, and then configure custom DNS settings via Network Manager.

In order to disable dnsmasq on Ubuntu Desktop, uncomment "dns=dnsmasq" in /etc/NetworkManager/NetworkManager.conf, and restart Network Manager.

$ sudo vi /etc/NetworkManager/NetworkManager.conf
#dns=dnsmasq
$ sudo service network-manager restart

Next, before attempting to add custom DNS server info, you first need to enable wired network settings on Network Manager, since that will allow you to use Networ kManager for configuring DNS settings.

Finally, proceed to add custom DNS server info via Network Manager as follows.

If you would like to use a custom DNS server in DHCP networking, choose "Automatic (DHCP) addresses only", and fill in custom DNS info of DHCP network settings. If you are using static networking, fill in custom DNS info similarly.

Once custom DNS info is saved via Network Manager, /etc/resolv.conf will be automatically updated to point to a custom DNS server, and all Ubuntu applications will correctly use the custom DNS server.

Support Xmodulo

This website is made possible by minimal ads and your gracious donation via PayPal or credit card

Please note that this article is published by Xmodulo.com under a Creative Commons Attribution-ShareAlike 3.0 Unported License. If you would like to use the whole or any part of this article, you need to cite this web page at Xmodulo.com as the original source.

Xmodulo © 2021 ‒ AboutWrite for UsFeed ‒ Powered by DigitalOcean