How to prevent /etc/resolv.conf from being overwritten

Posted on January 15, 2010 | Category: DHCP, Informational, Kubuntu, Linux, Networking, Ubuntu, Xubuntu, bash


Your /etc/resolv.conf file informs the networking end of Ubuntu some important information about where to look when it connects to the network or internet. The default parameters included in the resolv.conf file include:

Below is an example /etc/resolv.conf for a server that operates an internal nameserver using Bind9. the server.local is the nameserver name, the .30 address is the physical internal ip of the nameserver, and the following 2 nameservers of 8.8.8.8 and 8.8.4.4 are Google’s public nameservers.

domain server.local search server.local nameserver 10.1.10.30 nameserver 8.8.8.8 nameserver 8.8.4.4

If you are not operating a DHCP server on your network or your home router does not allow you to change your DNS settings, there is a method to allow you to manually change your /etc/resolv.conf file and keep the changes. You can change your resolv.conf file manually, but when you restart your computer, it will look towards the router for the network settings. In other words, it will overwrite your hard work.

Once you have manually edited your resolv.conf file and are happy with the changes, use the following command to prevent the file from being overwritten.

sudo chattr +i /etc/resolv.conf

Revetting back to a writable file, or if you make errors in your file use this command
sudo chattr -i /etc/resolv.conf

Similar Articles

Leave a Reply

CAPTCHA Image CAPTCHA Audio
Refresh Image

Design: YGoY TopOfBlogs