I have finally migrated to 12.04 from 7.10. I have one last part to complete but I am stumped. I am using Puppet on each server, and in the past I have included a nameserver address and a search domain name for the puppetmaster in resolv.conf.
search puppetmaster.com
nameserver 192.168.1.XXX
In 12.04 resolv.conf gets overwritten when rebooted. I cannot use a static IP for these, so using the /etc/network/interfaces to help me out is a nill point.
# 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
nameserver 127.0.0.1
Is there a way to get resolvconf to handle this either in the head, tail or base? If there is, are there any examples I can use to tweak on my server.
Any help is much appreciated.
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.
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 inresolv.conf
.Then tell resolvconf to regenerate
resolv.conf
.I think the answer is check your
/etc/dhcp/dhclient.conf
, i.e. don't requestdns-nameservers
from your dhcp client.Then update your
/etc/network/interfaces
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
:As an example for Google DNS, you may want to use this:
Second
Edit your DHCP configuration file, located at:
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 :
In 16.04:
As many other answers state this has to do with
resolvconf
being installed in your system.So the best way to keep something in
resolv.conf
that won't get lost on reboot is to include it in resolvconf configuration files that are in:In there go for the
head
file. Whatever you put there will be written at the top of/etc/resolv.conf
So everything will go to something like this:
Please look at
resolvconf
's man page. You can force inclusion of certain DNS settings by creating e.g./etc/resolvconf/resolv.conf.d/base
:There are other special files (head and tail), these may help you achieve what you want.
For me, the above answers were inadequate for the following reasons:
resolvconf
, just plain/etc/resolv.conf
.chattr +i
to lock downresolv.conf
seems too hacky. I need Puppet to be free to make changes when necessary./etc/network/interfaces
doesn't preventresolv.conf
from being overwritten; it simply specifies the name servers that should be written. For me, specifying the name servers wasn't the point. I'm trying to setoptions timeout:1
andoptions attempts:1
in myresolv.conf
file.The best solution I found overrides the default behavior of
dhclient
using its documented hooks.Create a new file at
/etc/dhcp/dhclient-enter-hooks.d/nodnsupdate
with the following contents:Then make the file executable:
Now when dhclient runs -- either on reboot or when you manually run
sudo ifdown -a ; sudo ifup -a
-- it loads this scriptnodnsupdate
. This script overrides an internal function calledmake_resolv_conf()
that would normally overwriteresolv.conf
and instead does nothing.This worked for me on Ubuntu 12.04.
This may just be some weird quirk in my machine, but someone else might have the same corner case.
I tried numerous ways to get my ISP nameservers included in /etc/resolv.conf with no success:
I included them in
/etc/network/interfaces
and restarted networking. They didn't show up in/etc/resolv.conf
.I put them in
/etc/resolv.conf
explicitly, but of course they got overwritten. They did show up in/run/resolvconf/interface/eth0.inet
, but never made it to/etc/resolv.conf
.I tried configuring resolvconf for dynamic updates. No change.
Finally I read somewhere that if the local machine (127.0.0.1) shows up in
/etc/resolv.conf
any other nameservers are not included.In desperation I edited
/run/resolvconf/interface/lo.named
, deleted the only line in it (nameserver 127.0.0.1
) and restarted:ifdown eth0 && ifup eth0
./etc/resolv.conf then included my ISP nameservers for the first time! I ran
service network-manager restart
to see if it was stable and/etc/resolv.conf
still includes my ISP nameservers. Rebooted just to make sure and it's still there but/run/resolvconf/interface/lo.named
got reset to:nameserver 127.0.0.1
.Curiously restarting networking still works:
/etc/resolv.conf
still contains my ISP nameservers. I can't explain this (can someone?) but this might help someone stuck in the same spot.add on the last line eg:
Open up a terminal and type
the +i takes care that the file wont be reseted on a boot.
To undo the above
For more
Add entries in
/etc/resolvconf/resolv.conf.d/head
and run following command
add your nameserver to file /etc/resolvconf/resolv.conf.d/head. The file contains message that you had received:
that file should looks like this after adding 8.8.8.8