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

If you found this article helpful and would like to support my work, consider making a donation through PayPal. Your support helps me continue creating useful content and tutorials. Thank you!

Donate via PayPal: https://paypal.me/musaamin

2 Comments

  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 *