Menu

How to Change DNS Server in Linux

Taufik Nurhidayat
2 min read
#linux #tutorial

DNS (Domain Name System) is a system that stores data in the form of domain names. Domain names are recorded in the DNS Server, which will direct us to the IP address of that domain. For example, the website Nurhidayat.web.id is recorded in the DNS Server and must have a destination IP address so that users can access that web server.

social_cards/change_2bdns_2bin_2blinux_mcp6d1.png

DNS (Domain Name System) is a system that stores data in the form of domain names. Domain names are recorded in the DNS Server, which will direct us to the IP address of that domain. For example, the website Nurhidayat.web.id is recorded in the DNS Server and must have a destination IP address so that users can access that web server.

Usually, DNS Servers are set by the ISP so that we can access the internet easily. However, for Indonesia, DNS is usually set specifically so that we cannot access negative content. But sometimes, this can slow down our internet speed. To overcome this, we have to work around it by changing the DNS Server we use.

To set up the DNS Server on Linux, we can do it through settings > network. However, it often fails to apply, and instead, it still uses the default ISP DNS. To overcome the inability to change or replace DNS via the GUI from the settings, we do it through the terminal. To do this, open the terminal or usually with the shortcut Ctrl+Alt+T, then type the following command:

sudo nano /etc/resolv.conf

After pressing enter, we will find an IP address like:

# Generated by NetworkManager
nameserver 192.168.100.1

Perhaps the IP address will be different. Now, let’s change the nameserver to Google DNS 8.8.8.8 or Cloudflare DNS 1.1.1.1.

# Generated by NetworkManager
nameserver 8.8.8.8

Then press Ctrl+X, then y, and Enter. Now we have changed or replaced the DNS Server on Linux. Try pinging to see if there is any change in ping speed.