My ISP asked me to use custom nameserver settings. I have placed these in /etc/resolv.conf. Unfortunately, every time I reboot the computer, the contents of this file is changed. To connect to the Internet, I must first edit that file. How can I ensure that this file does not change?

  • 1
    What OS are you running?
    – gabe.
    Commented Feb 14, 2012 at 3:15
  • I am using Debian 6.
    – Village
    Commented Feb 14, 2012 at 6:07
  • Just as a friendly bit of advice, if any of the answers below turned out to be the one you needed, please accept one. It's good etiquette and it makes people more likely to try to answer your questions. Commented Feb 17, 2012 at 17:43
  • I have not found the answer yet.
    – Village
    Commented Feb 23, 2012 at 23:58

5 Answers 5


In all likelihood the culprit is NetworkManager -- it rebuilds /etc/resolv.conf on startup/shutdown and whenever your managed network connections change.

Your best bet, unless you want to strip parts of your install out of your system, is to add your user to the netdev group (sudo adduser myuser netdev will do the trick) and then using network-manager-gnome or network-manager-kde depending on your preferred flavor to manage settings and specify your DNS servers. A useful tutorial can be found here.

Alternately, you can dig into /etc/network/interfaces and specify that the network connection you use to connect to the internet is not to be managed by NetworkManager, then add the keyword dns-nameservers to the stanza for that interface.

  • 1
    You can specify nameservers in networkmanager configs per connection basis.
    – Manwe
    Commented Feb 14, 2012 at 10:06
  • That's what I implied, yes. Commented Feb 14, 2012 at 10:38
  • I do not use GNOME, and I could not find any NetworkManager package anywhere in the apt database.
    – Village
    Commented Feb 23, 2012 at 23:57
  • It's called network-manager in the apt package database. Commented Feb 24, 2012 at 5:44

Take a look at the resolvconf package -- its purpose is to intercept resolv.conf changes (e.g. by DHCP clients). It can run small scripts when that happens, and it can prepend, append, or override settings written into resolv.conf

 Resolvconf is a framework for keeping up to date the system's
 information about name servers. It sets itself up as the intermediary
 between programs that supply this information (such as ifup and
 ifdown, DHCP clients, the PPP daemon and local name servers) and
 programs that use this information (such as DNS caches and resolver

If you are using ppp to connect to your isp, then pppd will run /etc/ppp/ip-pre-up after it connects, but before bringing up the network interface. Most systems also have an /etc/ip-up that gets run after the network interface is brought up, and that is usually a script that runs everything in the directory /etc/ip-up.d/. Also, most systems already have a script in /etc/ip-up.d/ that takes care of setting up /etc/resolv.conf. You can use any of these scripts to make sure nameservers are set up.


If you're using the Dynamic Host Configuration Protocol (DHCP), then it will configure your network settings automatically, which includes the address, the gateway and the nameserver, among others. When this happens, resolv.conf, or any other place for this kind of network configuration, gets changed, by design.

Check your system documentation to know what's the correct way to provide static DNS settings. For example, right now my resolv.conf reads

# Generated by dhcpcd from eth1
# /etc/resolv.conf.head can replace this line
# /etc/resolv.conf.tail can replace this line
  • My Internet connection does not use DHCP.
    – Village
    Commented Feb 23, 2012 at 23:58

For anyone who might stumble upon this issue: I fixed it in my router.

My computer is connected to my router, which is connected to my modem which goes ultimately to my provider.

In resolv.conf I found the address of my router as the first nameserver and then the address of my modem. Since my router didn't have any nameserver tables it wouldn't give any useful response, but it took quite some time before it gave a response at all, so each time I did a resolve request, it tried my router first which took a lot of time, then it would go to my modem.

So I needed some way to have my modem address as first nameserver in resolv.conf. Now I just used DHCP in Debian so I figured my router must give me this wrong nameserver. So I looked into my router configuration and found that I could specify static DNS servers (I have a Linksys router). I set the address of my modem in there and now after every reboot Debian has my modem address as first nameserver in resolv.conf!

Hope that helps anyone.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .