How To Edit resolv.conf in Ubuntu 14.04

In Ubuntu 14.04 server,  when you edit the file 'resolv.conf 'directly, the changes you made will be lost after the server is restarted.

What is resolv.conf?

The file resolv.conf is a file in Linux (and other operating systems) which contains information that points to the IP Address of the DNS server. A typical would be like:




This shows that the computer will first look for the DNS server with IP Address 8.8.8.8 ( This is Google's DNS server). If it can't find the 8.8.8.8 server, it will look for a local DNS server 192.168.0.254. 

This order is actually incorrect.  The ideal sequence is the computer must first look for a local DNS server then a public DNS server.

Question how to edit the data in resolv.conf permanently. As the comment on the file states"

#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN

If you edit resolv,conf directly, the information will be reverted to its original content once your reboot your computer. 

How to Edit resolv.conf

Before you edit resolv.conf make sure that your network card is set to static IP Address.  Read the instructions here.


If you take a look at the manual page of resolvconf by typing:

  $ man resolvconf  
You will this information:

man resolvconf

This tells us that this is the file that we need to edit.

$ sudo nano /etc/resolvconf/resolv.conf.d/base
then enter the name servers in order like in the image below:


Press CTRL-X then 'Y' and Enter.

Finally, you update your resolvconf by typing:


 $ sudo resolvconf -u 

 To verify if your new resolvconf configuration has been implemented, type:

$ cat /etc/resolv.conf 
 You should  see:



I hope this helps. If you're still have a problem in changing the information in resolv.conf, feel free to ask me through the comment box below.





Comments