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.


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

echo "nameserver" >> /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.

| improve this answer | |
  • I'm glad it worked! Please do mark the question as solved :) – Joel E Salas Feb 13 '13 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 despite Google running the DNS on more than one machine. – Skaperen Feb 13 '13 at 6:55

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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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