The "resolv.conf" file becomes empty after each restart [duplicate]

The "/etc/resolv.conf" file becomes empty after each restart and I lose the DNS data set in it. It only contains the following text each time:

# Generated by NetworkManager

What should I do?


Solution 1:

That file has 2 comments in it:

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN

Why not listen to the people that made/maintain this file? ;-)

resolveconf

From the man page:

Normally the resolvconf program is run only by network interface con‐ figuration programs such as pppd(8) (for ppp interfaces); by DHCP clients such as dhclient(8); by ifup(8) and ifdown; and by DNS caches such as dnsmasq(8) (for the loopback interface). These programs obtain nameserver information from some source and push it to resolvconf.

Command line

The administrator can run resolvconf from the command line to add or delete nameserver information, but this is not normally necessary or advisable.

Please use the method described here: How do I add a DNS server via resolv.conf? (Randall Cook seems the easiest and works for servers too).