I deleted my resolv.conf how do I get it back or how do I create it again

/etc/resolv.conf is automatically generated upon reboot by resolvconf if its a symbolic link to /run/resolvconf/resolv.conf (the file resolvconf writes to), you don't need to create it or edit it. You can put your name servers in /etc/network/interfaces using the following syntax so that they get added to /etc/resolv.conf automatically:

dns-nameservers <IP_address> <IP_address> <IP_address>

For example:

dns-nameservers 8.8.8.8 8.8.4.4

you should add this line at the end of your static IP configuration block.

If you have removed the symlink /etc/resolv.conf, run sudo dpkg-reconfigure resolvconf and you will come up with a set of questions to set it right again. Now do a reboot or run the following:

sudo ifdown eth0 && sudo ifup eth0  ##Change interface name accordingly

Everything should be fine.


To restore the symbolic link /etc/resolv.conf -> ../run/resolvconf/resolv.conf, execute the command sudo dpkg-reconfigure resolvconf at a command prompt.

If you are configuring your Internet-facing network interface using the ifup utility (whose configuration file is /etc/network/interfaces) then add nameserver information to the corresponding stanza in /etc/network/interfaces. Usually this entails adding at least a dns-nameservers option to the stanza in question. E.g.,

iface eth0 inet static
    address 192.168.22.33
    netmask 255.255.255.0
    dns-nameservers 192.168.22.1

Then when you ifup eth0, the address 192.168.22.1 will be added by resolvconf to resolv.conf (on an option line: nameserver 192.168.22.1).


You could also run:

sudo ln -s /run/resolvconf/resolv.conf /etc/resolv.conf

To restore the symbolic link.