How to Change DNS Settings in Ubuntu 18.04 LTS

People change DNS settings for a lot of reasons. Sometimes the websites are not loading properly, sometimes the scripts of the web page are not functioning properly. Usually flushing the DNS cache can help resolve most of the issues but if it is not working for you then changing the DNS settings might help you because changing the DNS settings in Ubuntu can help us resolve a lot of errors.

Apart from that if you want to use a custom DNS then this guide is also for You. There are two ways to change the DNS settings in Ubuntu which are as follow:

Change DNS Settings using the User Interface

To simply learn how to change the DNS settings in Ubuntu using the user interface kindly following the steps below:

Open the Ubuntu System Settings and Navigate to Network from there.

Ubuntu System Settings

When you open the Network, you will probably see a list of all the Networks that are in your vicinity.

Network Settings

Click the on the setting button next to the Network name in the list to which you are connected.

On doing so a New Window will open with a lot number of tabs, with one of them with the label of “IPv4 Settings”. Click on it.

Network details

Upon opening the “IPv4 Settings” Tab you will find a Field of “DNS”. Here you can write the DNS server you want to use. Also note when want to use your own DNS you have to select the

IPv4 Settings > DNS

If you want to use more than one DNS, then you can enter and separate them with a comma.

Change DNS using the Ubuntu Terminal

If you are a hardcore programmer and don’t like fixing things using the user interface, then need not to worry. You can also change the DNS settings using the built-in terminal.

To simply learn how to change the DNS settings in Ubuntu using terminal kindly following the steps below:

First of all, you will need to add the nameservers to the dnsmasq config file. But unfortunately, the dnsmasq isn’t installed On Ubuntu by default. So, in order to proceed with changing the DNS settings using built-in terminal, we will first have to install dnsmasq.

You can do it by launching the terminal and write

sudo apt-get install dnsmasq

Install dnsmasq

After the installation of dnsmasq you can finally edit the config file with the use of the following command:

sudo nano /etc/dnsmasq.conf

Open dnsmasq.conf file

After entering the above command, the config file will open, and you need to find the line where it says, “Add other nameservers here”. Once found you can replace it with the desired DNS server address as shown in the example below:

Add other nameservers here

Here you have it, folks. Using one of the methods mentioned above, you can change the DNS Settings in Ubuntu 18.04 LTS. Do let us know if this guide solved your problem and if not then feel free to ask us anything in the comment section below.