Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm running some tests on a Debian server. The network in which this server is located has two DNS servers (I don't know why and I can't change this). I used to need to point /etc/resolv.conf to one of these servers and I recently had to change which server I use. Since I changed /etc/resolv.conf to point to the new server, the configuration keeps changing behind my back every few days (it changes back to the old server).

For all I know, the machine has not rebooted. What should I check to figure out why this happens, and how can I stop it?

share|improve this question

3 Answers 3

You are probably using DHCP for automatic IP configuration.

Best option to try:

/etc/dhclient.conf 

or

/etc/dhcp/dhclient.conf 

file contains configuration information for dhclient. You can toggle the DNS updates/ point to different DNS server from this file. The man pages for DHCLIENT.CONF and DHCP-OPTIONS point out that in dhclient.conf, you should add this:

option domain-name-servers 8.8.8.8 8.8.4.4

where

8.8.8.8 8.8.4.4

are DNS server IPs

Following link have more scenarios/possible solutions covered.

share|improve this answer
    
I've just tried option #3 in the article you linked to. I think this is the best way to proceed since it is the method that least affects the the current server configuration. I'll give it a couple of days to see if it works as expected. Thanks. –  André Caron Apr 17 '12 at 20:30
    
We really do prefer answers to have content, not just pointers to content. Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. –  Iain Apr 17 '12 at 20:51
    
@lain: This still the most useful answer to the question. I don't feel it merits a downvote because it's only a link. –  André Caron Apr 17 '12 at 21:09
    
@lain : yes updated the answer –  kaji Apr 18 '12 at 5:24
    
@AndréCaron: It may be useful 'today' but links have a habit of going dead so it's not useful for tomorrow. –  Iain Apr 18 '12 at 13:05

Is your setup running NetworkManager? Consider disabling it if that suits your needs.

share|improve this answer
    
either that or dhcp is doing that for you.. –  alexus Apr 17 '12 at 20:14

On a server (or anything that's not being moved around a lot, or at least has a static IP) you don't need tools that automagically configure networking for you. It just gets in the way.

Remove the following:

apt-get --purge remove resolvconf network-manager

Then kill any dhcp client that may still be running:

ps -ef|grep dhcp
kill PID   <-- i.e. the ID of any process you found

Once done I am pretty sure your networking and resolv.conf will not mysteriously change anymore.

After that make sure your resolv.conf as well as your network configuration are configured the way you want it to be. Any changes you make will stay that way.

share|improve this answer
    
I'm really quite ignorant of network configurations, so do you have any relevant documentation on what this does and why it works? I don't want to blindly paste commands into the shell and cross my fingers... –  André Caron Apr 17 '12 at 20:03
    
Networkmanager uses some logic to determine what kind of networking you need, like wireless, or cable, and change the connection accordingly. Resolvconf is a framework for keeping up to date the system's information about name servers. Neither is needed on a system where such information remains static. –  aseq Apr 17 '12 at 20:05
    
But I don't want to disable everything the DHCP service does. I only want to prevent it from "updating" the resolv.conf file. It seems the apt-get --purge remove resolvconf network-manager would do (only) this, but why should I kill the running DHCP service? –  André Caron Apr 17 '12 at 20:26
    
If you're running a dhcp server and you need it leave it running. Just kill the dhcp-client that may be running. You can recognise it by the "client" part when you do "ps -ef|grep dhcp". If it's not there all the better. –  aseq Apr 17 '12 at 20:37
    
I've just tried the instructions for option #3 in kaji's answer since it seems to be the approach that least affects the server configuration. Also, I'm sure it will keep running as expected after a server reboot. I'm not so sure about your approach (just killing the dhcp-client service). –  André Caron Apr 17 '12 at 20:44

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.