github linkedin
Ubuntu splits all after 127.0.0.1 in dns-nameservers flag
Ubuntu manages local DNS settings by “resolvconf” package and settings could be set in /etc/network/interfaces file.

For example

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
  iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
  address 192.168.122.20
  netmask 255.255.255.0
  gateway 192.168.122.1
  dns-nameservers 127.0.0.1 8.8.8.8
  dns-search local.lan cloud.lan

In detail “man interfaces” or “man resolvconf”.

I have local dns server on 127.0.0.1. And i’ve plunged in strange behavior with “dns-nameservers” flag.

If i set

dns-nameservers 8.8.8.8 127.0.0.1

It works like a charm.

cat /etc/resolv.conf

# 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 8.8.8.8
nameserver 127.0.0.1
search local.lan cloud.lan

But if I put 127.0.0.1 as first nameserver

dns-nameservers 127.0.0.1 8.8.8.8

There is no nameservers after 127.0.0.1 …

cat /etc/resolv.conf 

# 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.lan cloud.lan

But I want to be able to use local dns as preferable plus other public nameserver.

What i’ve found here /etc/resolvconf/update.d/libc (this file related to resolvconf package)


# Set TRUNCATE_NAMESERVER_LIST_AFTER_LOOPBACK_ADDRESS=no
# to allow additional nameserver addresses to be listed in
# resolv.conf after an initial loopback address 127.* or ::1.

SOLUTION:

echo “TRUNCATE_NAMESERVER_LIST_AFTER_LOOPBACK_ADDRESS=no” >> /etc/default/resolvconf

Used ubuntu 12.04 LTS