How do I include lines in resolv.conf that won't get lost on reboot?

It's probably better to have your DNS server be able to resolve 'puppet' to the right address, and either to have your DHCP server hand out the DNS nameserver address and search list or else (if you have static IP addresses) to have something like the following in /etc/network/interfaces.

iface eth0 inet static
    address 192.168.3.3
    netmask 255.255.255.0
    gateway 192.168.3.1
    dns-search example.com
    dns-nameservers 192.168.3.45 192.168.8.10

But if you do want to do it via the resolvconf configuration files you will want to edit /etc/resolvconf/resolv.conf.d/base. In that file, put in your info as you would in resolv.conf.

nameserver 192.168.1.XXX

Then tell resolvconf to regenerate resolv.conf.

sudo resolvconf -u

I think the answer is check your /etc/dhcp/dhclient.conf, i.e. don't request dns-nameservers from your dhcp client.

Then update your /etc/network/interfaces

auto eth0
iface eth0 inet dhcp
dns-search google.com
dns-nameservers dnsserverip

Then your resolv.conf will get auto configured the way you want it.

Add to the dns-search and then run a /etc/init.d/networking restart (even though this script's deprecated it still works).


This is likely caused by DHCP configuration when you first installed Ubuntu. Try this 3-step process to handle this auto configuration issue.

First

Edit your interface configuration, which is located in: /etc/network/interfaces

Add this line below iface lo inet loopback:

dns-nameservers yourdns youraltdns

As an example for Google DNS, you may want to use this:

dns-nameservers 8.8.8.8 8.8.4.4

Second

Edit your DHCP configuration file, located at:

/etc/dhcp/dhclient.conf

Mark the syntax as a comment using # on every line or simply remove every request name-server. In 16.04, you may not be required to make any changes here.

Third

Restart your networking by using this command :

/etc/init.d/networking restart

In 16.04:

sudo ifdown -a
sudo ifup -a