How To Make Changes In resolv.conf Permanent in Ubuntu [Quick Tip]

When you change the DNS configuration using /etc/resolv.conf file, you must have noticed that the changes are not permanent. A reboot and your changes might revert to the original settings. I had this issue when I changed the DNS setting to watch Netflix outside USA. Editing resolv.conf solved my problem but for the moment only. My changes were not permanent and when I looked at resol.conf file again, I found why it is so. The file clearly mentioned it and I did not pay attention to it:

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN

So, as said, my changes were overwritten. Editing resolv.conf is good for instant testing but the question arises how to make changes in resolv.conf permanent in Ubuntu or any other Linux system.

In this quick tip, I’ll discuss the solution that you could use to make the changes in resolv.conf permanent.

Make permanent changes in resolv.conf:

To make the DNS related changes in resol.conf permanent, you need to change the DHCP configuration file named dhclient.conf. You can find the file in this location: /etc/dhcp/dhclient.conf

You’ll see lines like these:

#supersede domain-name "fugue.com home.vix.com";
 #prepend domain-name-servers 127.0.0.1;

Remove the preceding “#” and use the domain-name and domain-name-servers which you want. Save it. Now the DNS related changes will be permanent.

Alternate workaround to make permanent changes in resolv.conf:

This workaround needs a program resolvconf to be installed in your system. Normally this program is installed in many Linux systems by default but to make sure it is, use the following command in terminal (Ctrl+Alt+T ) in Ubuntu:

sudo apt-get install resolvconf

Once you have made sure that the resolvconf is installed, edit the configuration file using the following command:

sudo gedit /etc/resolvconf/resolv.conf.d/base

Save it. Now the settings in resolv.conf will be permanent.

I hope this quick tutorial helped you in changing DNS settings and making those changes permanent. Any questions, suggestions, a word of thanks are welcomed. Ciao :)

Become a Better Linux User

With the FOSS Weekly Newsletter, you learn useful Linux tips, discover applications, explore new distros and stay updated with the latest from Linux world

It's FOSS

Great! You’ve successfully signed up.

Welcome back! You've successfully signed in.

You've successfully subscribed to It's FOSS.

Success! Check your email for magic link to sign-in.

Success! Your billing info has been updated.

Your billing was not updated.