Actually, on a ubuntu 16.04 server, my /etc/resolv.conf is :
# 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 213.186.33.99
search local
I want to put "nameserver 127.0.0.1" at the top.
I modified my network config file to:
auto lo
iface lo inet loopback
auto ens3
iface ens3 inet dhcp
dns-nameservers 127.0.0.1 <--- added this
but the nameserver 127.0.0.1 has been set at the bottom :
# 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 213.186.33.99
nameserver 127.0.0.1
search local
I modified /etc/dhcp/dhclient.conf to ask to prepend 127.0.0.1 :
prepend domain-name-servers 127.0.0.1;
But now, the nameserver dynamically found by DHCP has disappeared :
# 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
search local
So how can I have "nameserver 127.0.0.1" at the top AND the nameserver dynamically found by DHCP bellow ?
Best Answer
As mentioned in the comment line, the file is generated by
resolvconf
(8). It is configured withresolvconf.conf
(5):And the options that affects the processing order: