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

I have installed dnsmasq and added nameserver to the resolv.conf file so I can use wildcards in my apache configuration. But every time I restart the computer or change Wi-Fi connection I have to add it again to get it working.

Why is this happening and how can I make it work ?

share|improve this question
Isn't it /etc/resolv.conf – RobotHumans Mar 23 '12 at 11:00
Yes it is :)... – skowron-line Mar 23 '12 at 11:09

If you are running an Ubuntu system prior to 12.04 that hasn't yet been upgraded to 12.04 or later, or if you have removed the resolvconf package then install the resolvconf package.

sudo apt-get install resolvconf

If resolvconf was already installed, ensure that /etc/resolv.conf is a symbolic link to ../run/resolvconf/resolv.conf.

sudo dpkg-reconfigure resolvconf

Once you have installed the dnsmasq package (not to be confused with the dnsmasq-base package) you do not need to edit /etc/resolv.conf. The dnsmasq initscript causes (via resolvconf) '' to be added to resolv.conf when dnsmasq starts, provided the value of IGNORE_RESOLVCONF is not set to yes in /etc/default/dnsmasq.

Doubters, please read /etc/init.d/dnsmasq.

P.S. In Ubuntu 12.04 there is a complicating factor. NetworkManager by default starts a dnsmasq process which listens exclusively on This conflicts with the "standalone" dnsmasq process; only one of the two can start. This is a known bug, #959037, which was fixed in Ubuntu 12.10 (by moving NM-dnsmasq's listen address to If you are still running Ubuntu 12.04 and you want to run standalone dnsmasq then you should either disable the NetworkManager-controlled dnsmasq (by commenting out "dns=dnsmasq" in /etc/NetworkManager/NetworkManager.conf) or configure the standalone dnsmasq not to listen on

share|improve this answer

You need to specify your preferred dns server in Network Manager. Otherwise, it will continue to overwrite the config-file. See What is the proper way to change the DNS IP?

share|improve this answer
Nice one, but I cant insert # with # at the end its not valid address – skowron-line Mar 23 '12 at 11:12
# is just a comment. – Egil Mar 23 '12 at 11:22
but without # this will not work – skowron-line Mar 23 '12 at 11:31
Strange. is it not documented in the resolv.conf man-page. – Egil Mar 23 '12 at 11:55 I used this tutorial – skowron-line Mar 23 '12 at 12:24

Buidling on Egil's answer. If it is network-manager clobbering the file, someone on ubuntuforums resolved it by removing the resolvconf package. This may or may not still work since the thread is a little old.

share|improve this answer
The problem is not the resolvconf package. – jdthood Oct 29 '12 at 14:46

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.