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 cannot ping/reach any website/service by name (e.g. ping

I could temporarily fix this by changing to my router in /etc/resolv.conf But that file gets overwritten.

How can I permanently fix this?

To be clear, I don't need a DNS server, I just want my server to be able to use DNS from DHCP.

share|improve this question
up vote 3 down vote accepted

I solved it in another way, because I have the impression the solution above is doing what was not asked, i.e. implementing a dhcp server.

I deleted the bind9 and dhcp3-server with

sudo aptitude remove bind9 dhcp3-server

and restarted networking with

sudo /etc/init.d/networking restart

I also changed the file /etc/NetworkManager/NetworkManager.conf. Its contents looks like:



After modifying this file, I had to restart the Network Manager service:

sudo service network-manager restart

Now the dhcp client seems to set the dns server to the one provided by dhcp.

share|improve this answer

                                        Setup Static DNS Servers in Ubuntu 12.04 (Precise Pangolin)

sudo nano /etc/dhcp/dhclient.conf

Then change the line highlighted to

prepend domain-name-servers x.x.x.x, y.y.y.y;

enter image description here


Ubuntu 12.04 changes the way DNS setup is handled. Rather than adding nameservers to /etc/resolv.conf, they need to be added to /etc/network/interfaces.

Edit /etc/network/interfaces, look for your primary ethernet device (such as eth0), and add this line under your primary ethernet device:


And then restart your networking:

/etc/init.d/networking restart


share|improve this answer
Note that this also breaks Vagrant and you need to add this line in your config: config.vm.customize ["modifyvm", :id, "--natdnshostresolver1", "on"] – user81043 Aug 3 '12 at 12:45

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.