Linux – Regenerating /etc/resolv.conf

linuxUbuntu

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.

Best Answer

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.

Related Topic