Ubuntu – Why are the dns options specified in /etc/network/interfaces not parsed by resolvconf

networkingresolv.confUbuntu

I have a Ubuntu 14.04 server which has two IP addresses specified on a single interface. They are defined in /etc/network/interfaces like so:

auto em1
iface em1 inet static
    address 192.168.1.2
    netmask 255.255.255.0
    gateway 192.168.1.1
    # dns-* options are implemented by the resolvconf package, if installed
    dns-nameservers 192.168.1.10 192.168.1.11

iface em1 inet static
    address 192.168.1.3
    netmask 255.255.255.0

As per the debian wiki I have specified multiple IP addresses in the modern style by simply declaring multiple iface stanzas referring to the same interface.

However, when the networking on this server comes up, /etc/resolv.conf is empty but for the standard header:

# 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

And all DNS lookups are therefore failing as it does not try to contact the nameservers.

I've clearly specified the local nameservers to use in the dns-nameservers line in /etc/network/interfaces above. Why are they not in resolv.conf?

Actual IP addresses have been changed to protect the innocent

Best Answer

It turns out that what seems to be happening is that when resolvconf parses the interfaces file, because I have multiple iface stanzas that target the same interface, the specified dns options in the first stanza are discarded when resolvconf then parses the second iface stanza.

If I rewrite my /etc/network/interfaces to look like this:

auto em1
iface em1 inet static
    address 192.168.1.2
    netmask 255.255.255.0
    gateway 192.168.1.1

iface em1 inet static
    address 192.168.1.3
    netmask 255.255.255.0
    # dns-* options are implemented by the resolvconf package, if installed
    dns-nameservers 192.168.1.10 192.168.1.11

Then resolv.conf gets generated with the content I expect:

# 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 192.168.1.10
nameserver 192.168.1.11