Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The default DNS server was running too slowly, so I changed the configuration by adding a nameserver.

/etc/resolv.conf :

domain ***
search ***

But the file will is changed back to the default automatically after a while.
Is there any method to solve this problem?

share|improve this question
It's redundant to have config lines for both "search" and "domain", and "domain" will be ignored if "search" is set. – bgvaughan May 31 '11 at 1:18
Actually, if both "domain" and "search" are set, the last one is used. Ref: resolv.conf man page. – jdthood Oct 30 '12 at 8:14
Please note that resolv.conf handling has fundamentally changed since Ubuntu 12.04. – jdthood Dec 7 '12 at 8:18

In a full ubuntu these files are rewritten by network-manager, It's better to manage these changes by using the GUI in System > Settings > Network Connections.

Without desktop I think this is controlled by a serie of entries in dbus / gconf. So if the network is reliable I think its better uninstall network manager and roll your own manual configuration.

Also there's something called nmcli which is a sort of command line tool for network-manager.

share|improve this answer
You can pre-empt network-manager by configuring network connections in /etc/network/interfaces. See "man 5 interfaces". If this is a desktop, not a laptop, and you use the same network configuration all the time, than you may prefer to use this approach, and to uninstall network-manager. – bgvaughan May 31 '11 at 1:24

The easiest way is probably to install the resolvconf package and then add whatever configuration you want to /etc/resolvconf/resolv.conf.d/head (you can ignore the scary warning, it's only there so that it ends up in the generated /etc/resolv.conf);    then run resolvconf -u to update /etc/resolv.conf.

share|improve this answer
This is the right answer. thiest's answer only applies to the desktop version of Ubuntu. kit.yang's answer removes some functionality for dhcp clients. This answer puts your DNS server choices up front but allows for some helpful fallbacks if those aren't reachable. – Avery Chan Jun 22 '12 at 6:19

I found a method effective after trying some ways.
Modify the resolv.conf firstly.
Edit the configuration file of DHCP client.(location:/etc/dhcp3/dhclient.conf)

    request subnet-mask, broadcast-address, time-offset, routers,
    domain-name, domain-name-servers, domain-search,host-name, 
    netbios-name-servers, netbios-scope, interface-mtu,
    rfc3442-classless-static-routes, ntp-servers;


    request subnet-mask, broadcast-address, time-offset, routers, 
    host-name,netbios-name-servers, netbios-scope, interface-mtu,
    rfc3442-classless-static-routes, ntp-servers;

Delete domain-name, domain-name-servers, domain-search options.

share|improve this answer
I'm wondering if this would still work correctly with on domain-name-servers removed.... – belacqua Feb 22 '11 at 9:06
@jgbelacqua It can get the IP address by DHCP.But the file(/etc/ resolv.conf )still be changed by network-manager if you click the option auto ethernet.Uninstall network-manager may be a good choice. – kit.yang Feb 22 '11 at 10:44

Your Answer


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.