How to Set Permanent resolv.conf on Ubuntu

How to Set Permanent resolv.conf on Ubuntu

The file /etc/resolv.conf is a file containing the DNS resolver or IP address of the DNS server (nameserver) which functions to translate from domain names to IP addresses.

In Ubuntu 20.04, the default nameserver is 127.0.0.53.

For example, if you want to use Cloudflare’s (1.1.1.1) and Google’s (8.8.8.8) DNS servers as primary and secondary nameservers, put the IP address in the first and second lines.

Update to be like below.

Problem

The problem that occurs is the resolv.conf file will change back to how it was after the computer is restarted, which only contains the IP address 127.0.0.53. In the resolv.conf file there is also a comment DO NOT EDIT THIS FILE BY HAND – YOUR CHANGES WILL BE OVERWRITTEN , which means don’t change this file manually because the configuration will be overwritten again.

Solution

To solve the above problem is to use resolvconf service.

Install the resolvconf package.

Then activate and run the resolvconf service.

The results are as below.

Then enter the nameserver IP address in the head resolvconf configuration file.

Enter the nameservers under the comments.

Then run the resolv.conf update.

Verify by displaying the contents of the resolv.conf file.

If you want to change or add other nameserver IP addresses, change the head file again, and run the resolvconf update.

Good luck 🙂

Default image
Musa Amin
I am a Linux System Administrator and also write many tutorials about Linux, Cloud, and Open Source. Hire me via email hai[at]musaamin.web.id.

Leave a Reply