I cannot ping/reach any website/service by name (e.g. ping google.com).

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.


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.


                                        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


  • 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 clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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