Why would 127.0.0.1 in resolv.conf cause problems in DNS resolution?
1: Add dns-nameservers
and dns-search
options to /etc/network/interfaces.
auto eth1
iface eth1 inet static
address 162.226.130.121
netmask 255.255.255.0
gateway 162.226.130.126
dns-nameservers 8.8.8.8 162.226.130.126
dns-search m2osw.com
2: Remove all dns-
options from files in /etc/resolvconf/resolv.conf.d/
. That resolv.conf includes nameserver
options after nameserver 127.0.0.1
indicates that such cruft is present. If /etc/resolvconf/resolv.conf.d/tail is a symbolic link, make it a symbolic link to /dev/null
.
3: Downup eth1.
sudo ifdown eth1
sudo ifup eth1
4: Look in /etc/resolv.conf. Is nameserver 127.0.0.1
still there and are replies to DNS queries still delayed? If so then figure out where the nameserver 127.0.0.1
line is coming from. Something is registering the listen address 127.0.0.1 without starting a local nameserver at 127.0.0.1. (i) One possibility is the bind9 package. If you aren't running a local BIND nameserver then purge the bind9 package (sudo apt-get purge bind9
). If you are running a BIND nameserver that doesn't provide general Internet name service then edit /etc/default/bind9 and set RESOLVCONF=no
, then restart the nameserver. See: https://bugs.launchpad.net/ubuntu/+source/bind9/+bug/933723 (ii) Another possibility is that you have remnants of dnsmasq or similar package on the system. Purge that package. Also purge network-manager since you aren't using it.
5: Reboot and see if things have improved, then report back here.
Using a dns server with a loopback address (e.g. 127.0.0.1) causes problems:
All other dns server with a lower priority are ignored by resolvconf
.
The priority of dns servers is defined by the network interfaces with which the dns-server is defined.
See /etc/resolvconf/interface-order
and man 5 interface-order
.
Luckily there is an environment variable to change this behaviour:
TRUNCATE_NAMESERVER_LIST_AFTER_LOOPBACK_ADDRESS
See man 8 resolvconf
If put
TRUNCATE_NAMESERVER_LIST_AFTER_LOOPBACK_ADDRESS=no
in /etc/default/resolvconf
and restart the resolvconf
service all other dns server will show up in /etc/resolv.conf
.