1

I'm running Ubuntu 12.04 and I managed to stomp on my /etc/resolv.conf file. I believe this is the cause of me getting

ping: unknown host www.google.com

It says resolv.conf is auto generated but I cannot figure out how to regenerate this file back to its previous default settings. I've checked many forums and the man files and I am stuck.

Appreciate any help.

2 Answers 2

6

If you don't have a copy of it, simply recreate the /etc/resolv.conf like this:

echo "nameserver 8.8.8.8" >> /etc/resolv.conf

You can add more nameservers as necessary, one per line. This example uses Google's public DNS servers. That should get you back on your feet. In the future, you should look at using revision control like Git for your configuration files (pretty much everything in /etc and whatever other software you install), and eventually evolving to proper configuration management like Puppet or Chef.

2
  • I'm glad it worked! Please do mark the question as solved :) Feb 13, 2013 at 5:12
  • 1
    I would change the >> to > in distrust of generated nameserver lines that do not work. Once you know exactly what name servers you should use, then you can use those. I'd also include 8.8.4.4 despite Google running the DNS on more than one machine.
    – Skaperen
    Feb 13, 2013 at 6:55
2

Actually, though you can manually edit your resolv.conf file by hand, the correct Ubuntu-way (as of 12.04, iirc) is to run dpkg-reconfigure resolvconf. You can find your original resolv.conf file at /etc/resolvconf/resolv.conf.d/original, and /etc/resolv.conf is just a symlink to /run/resolvconf/resolv.conf which is generated at boot time by resolvconf package.

You must log in to answer this question.

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