5

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

I could temporarily fix this by changing 127.0.0.1 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.

2 Answers 2

6

                                        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

liberiangeek


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:

dns-nameservers 127.0.0.1

And then restart your networking:

/etc/init.d/networking restart

virtualmin

1
  • 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, 2012 at 12:45
3

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:

[main]
plugins=ifupdown,keyfile
dns=dnsmasq

[ifupdown]
managed=true

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .