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 NetworkManager 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 NetworkManager.
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 facts, 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 NetworkManager.
In order to disable dnsmasq on Ubuntu Desktop, uncomment "dns=dnsmasq" in /etc/NetworkManager/NetworkManager.conf, and restart NetworkManager.
Next, before attempting to add custom DNS server info, you first need to enable wired network settings on NetworkManager, since that will allow you to use NetworkManager for configuring DNS settings.
Finally, proceed to add custom DNS server info via NetworkManager 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 NetworkManager, /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.
Subscribe to Xmodulo
Do you want to receive Linux FAQs, detailed tutorials and tips published at Xmodulo? Enter your email address below, and we will deliver our Linux posts straight to your email box, for free. Delivery powered by Google Feedburner.
Did you find this tutorial helpful? Then please be generous and support Xmodulo!