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.

On Ubuntu 20.04, the default nameserver is

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

Update to be like below.


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 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.


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.


  1. Many websites have a long intro to describe what they’re about to show the reader how to do something. Thank you for getting right to the point right away.

Leave a Reply

Your email address will not be published. Required fields are marked *