IPv6 DHCP record too late, and other irregularities, in resolvconf interface-order

Bug #1094345 reported by Kevin Otte
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
resolvconf (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

I am using /etc/network/interfaces rather than NetworkManager on this machine. resolvconf is always writing the IPv4 nameservers and search domains before the IPv6. I would like the IPv6 resolver information to be given priority or a method to select the behavior.

kjotte@pegasus:~$ cat /etc/network/interfaces
# 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 inet6 auto
    dhcp 1
iface eth0 inet dhcp

kjotte@pegasus:~$ 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 172.31.3.4
nameserver 2001:470:8:64f::4
search nivex.lan home.nivex.net

ProblemType: Bug
DistroRelease: Ubuntu 12.10
Package: resolvconf 1.67ubuntu2
ProcVersionSignature: Ubuntu 3.5.0-21.32-generic 3.5.7.1
Uname: Linux 3.5.0-21-generic i686
NonfreeKernelModules: nvidia
ApportVersion: 2.6.1-0ubuntu6
Architecture: i386
Date: Fri Dec 28 15:33:41 2012
MarkForUpload: True
PackageArchitecture: all
SourcePackage: resolvconf
UpgradeStatus: Upgraded to quantal on 2012-05-10 (232 days ago)

Revision history for this message
Kevin Otte (nivex) wrote :
Revision history for this message
Thomas Hood (jdthood) wrote :

You should be able to get the behavior you want by editing /etc/resolvconf/interface-order.

Try this. In /etc/resolvconf/interface-order put a line

    eth*([^.]).inet6

before the existing line

    eth*

and then run

    resolvconf -u

Revision history for this message
Kevin Otte (nivex) wrote :

Tried the edit and ran resolvconf -u. No joy. Even tried an ifdown and ifup just to be sure. Still getting a resolv.conf as pasted above.

Revision history for this message
Thomas Hood (jdthood) wrote :

My apologies: my suggestion was based on the obviously mistaken assumption that you had specified nameserver addresses in /etc/network/interfaces whereas in fact you are using DHCP clients to get those addresses. DHCP clients register nameserver information with resolvconf using other record name suffixes than ifup itself uses. Ifup uses the suffix "inet" for the inet address family and "inet6" for the inet6 address family.

You wrote:
> iface eth0 inet6 auto
> dhcp 1
> iface eth0 inet dhcp

When you ifup eth0 with the "inet dhcp" configuration, dhclient registers nameserver information with the "dhclient" suffix.

I have never used "inet6 auto" and my home router doesn't do IPv6 DHCP so I can't easily investigate this aspect of your configuration. Please ifup eth0 and post the output of

    ls -l /run/resolvconf/interface
    for F in /run/resolvconf/interface/* ; do echo === $F === ; cat $F ; done

Revision history for this message
Kevin Otte (nivex) wrote :

kjotte@pegasus:~$ ls -l /run/resolvconf/interface/
total 8
-rw-r--r-- 1 root root 40 Dec 28 20:04 eth0.dhclient
-rw-r--r-- 1 root root 52 Dec 20 00:11 eth0.ip6.dhclient
kjotte@pegasus:~$ for F in /run/resolvconf/interface/* ; do echo === $F === ; cat $F ; done
=== /run/resolvconf/interface/eth0.dhclient ===
search nivex.lan.
nameserver 172.31.3.4
=== /run/resolvconf/interface/eth0.ip6.dhclient ===
search home.nivex.net.
nameserver 2001:470:8:64f::4

Revision history for this message
Thomas Hood (jdthood) wrote :

OK, it should suffice to add a line

    eth*([^.]).ip6.dhclient

before the existing line

    eth*

and then to run the following command to update resolv.conf.

    resolvconf -u

What remains is the question whether or not anything should be done to the resolvconf package.

I think so. Consider eth0 with inet, inet6, dhclient and ip6.dhclient records. These are currently ordered (alphabetically) as follows.

    eth0.dhclient
    eth0.inet
    eth0.inet6
    eth0.ip6.dhclient

For symmetry with the IPv4 case the ip6.dhclient record should come before the inet6 record.

    eth0.dhclient
    eth0.ip6.dhclient
    eth0.inet
    eth0.inet6

The present bug report (bug #1094345) wishes that the IPv6 records came before the IPv4 records.

    eth0.ip6.dhclient
    eth0.dhclient
    eth0.inet6
    eth0.inet

Is this (IPv6 over IPv4) something that everyone would/should want, or not?

Changed in resolvconf (Ubuntu):
status: New → Confirmed
summary: - order of resolvers always prefers IPv4
+ IPv6 DHCP record is too late in resolvconf interface-order
Revision history for this message
Kevin Otte (nivex) wrote : Re: IPv6 DHCP record is too late in resolvconf interface-order

This workaround is confirmed to work. Thanks much!

I personally believe, in light of the World IPv6 Launch and the continued adoption of IPv6, that this behavior should be the norm. I look forward to the continued discussion on this.

Thanks again.

Revision history for this message
Kevin Otte (nivex) wrote :

Not sure if this needs a separate bug report, but I have a machine in a similar configuration that uses a bridge for virtual machines, so it is br0 rather than eth0. I added a

br*([^.]).ip6.dhclient

to the interface-order file and it works as expected. Is this something you will want to address in the package as well, or is it too much an edge case?

Revision history for this message
Kevin Otte (nivex) wrote :

An additional note on ordering policy: when using NetworkManager the IPv6 records are listed first.

Revision history for this message
Thomas Hood (jdthood) wrote :

> Is this something you will want to address in the package as well

Yes, the behavior should be consistent across interface types.

> when using NetworkManager the IPv6 records are listed first

That certainly lends weight to the proposal that resolvconf also put IPv6 records first.

Revision history for this message
Thomas Hood (jdthood) wrote :

Consider eth0 with inet, inet6, dhclient and ip6.dhclient records. These are currently ordered (alphabetically) as follows.

    eth0.dhclient
    eth0.inet
    eth0.inet6
    eth0.ip6.dhclient

Observations:
* IPv4 comes before IPv6
* The prioritization of *dhclient versus inet* is inconsistent.

I propose to change the order to the following.

    eth0.inet6
    eth0.inet
    eth0.ip6.dhclient
    eth0.dhclient

That is:
* IPv6 before IPv4
* inet before dhclient

Rationale:
* NetworkManager prioritizes IPv6 before IPv4
* Putting inet before dhclient allows "dns-nameservers" to be used to override addresses of faulty nameservers coming in via DHCP

Accordingly, here is a first draft of a new factory-shipped interface-order file.

=== BEGIN ===
# interface-order(5)
lo.inet6
lo.inet
lo.@(dnsmasq|pdnsd)
lo.!(pdns|pdns-recursor)
lo
tun*
tap*
hso*
em+([0-9])?(_+([0-9]))*
p+([0-9])p+([0-9])?(_+([0-9]))*
eth*([^.]).inet6
eth*([^.]).inet
eth*([^.]).ip6.@(dhclient|dhcpcd|pump|udhcpc)
eth*([^.]).@(dhclient|dhcpcd|pump|udhcpc)
eth*
@(ath|wifi|wlan)*([^.]).inet6
@(ath|wifi|wlan)*([^.]).inet
@(ath|wifi|wlan)*([^.]).ip6.@(dhclient|dhcpcd|pump|udhcpc)
@(ath|wifi|wlan)*([^.]).@(dhclient|dhcpcd|pump|udhcpc)
@(ath|wifi|wlan)*
ppp*
*
=== END ===

Testing this by creating a bunch of fake records in a directory...

=== BEGIN ===
# /lib/resolvconf/list-records
lo.inet6
lo.inet
lo.dnsmasq
lo.pdnsd
lo
tun0
tap0
hso0
em0_0
p0p0_0
eth0.inet6
eth0.inet
eth0.ip6.dhclient
eth0.dhclient
wlan0.inet6
wlan0.inet
ath0.ip6.dhclient
wlan0.ip6.dhclient
ath0.dhclient
wlan0.dhclient
ppp0
ppp1
=== END ===

This probably needs some more tweaking. I am not sure what to do about tun, tap, hso and br so I haven't changed these. The change that worries me the most is putting eth0.inet before eth0.dhclient whereas currently (resolvconf 1.69 and earlier) eth0.inet comes after eth0.dhclient. I think that the change shouldn't affect too many people because few people have a stanza like the following.

    iface eth0 inet dhcp
        dns-nameservers 1.2.3.4 # Overridden by DHCP-provided nameserver addresses

Comments and advice are most welcome.

Revision history for this message
Thomas Hood (jdthood) wrote :

The proposed new interfaces-order file that I just posted (comment #11) can be compared with the current one.

=== BEGIN ===
# interface-order(5)
lo.inet*
lo.dnsmasq
lo.pdnsd
lo.!(pdns|pdns-recursor)
lo
tun*
tap*
hso*
em+([0-9])?(_+([0-9]))*
p+([0-9])p+([0-9])?(_+([0-9]))*
eth*
ath*
wlan*
ppp*
*
=== END ===

Here is the diff betweent them.

=== BEGIN ===
jdthood@tenerife:/etc/resolvconf$ diff -u interface-order_ORIG interface-order
--- interface-order_ORIG 2012-12-29 19:57:56.027833090 +0100
+++ interface-order 2013-01-01 21:27:20.558605846 +0100
@@ -1,7 +1,7 @@
 # interface-order(5)
-lo.inet*
-lo.dnsmasq
-lo.pdnsd
+lo.inet6
+lo.inet
+lo.@(dnsmasq|pdnsd)
 lo.!(pdns|pdns-recursor)
 lo
 tun*
@@ -9,9 +9,15 @@
 hso*
 em+([0-9])?(_+([0-9]))*
 p+([0-9])p+([0-9])?(_+([0-9]))*
-#eth*([^.]).ip6.dhclient
+eth*([^.]).inet6
+eth*([^.]).inet
+eth*([^.]).ip6.@(dhclient|dhcpcd|pump|udhcpc)
+eth*([^.]).@(dhclient|dhcpcd|pump|udhcpc)
 eth*
-ath*
-wlan*
+@(ath|wifi|wlan)*([^.]).inet6
+@(ath|wifi|wlan)*([^.]).inet
+@(ath|wifi|wlan)*([^.]).ip6.@(dhclient|dhcpcd|pump|udhcpc)
+@(ath|wifi|wlan)*([^.]).@(dhclient|dhcpcd|pump|udhcpc)
+@(ath|wifi|wlan)*
 ppp*
 *
=== END ===

Revision history for this message
Thomas Hood (jdthood) wrote :

@Kevin: Can you please test the interface-order file I posted in comment #11? Let me know if the file works properly for you.

Thomas Hood (jdthood)
summary: - IPv6 DHCP record is too late in resolvconf interface-order
+ IPv6 DHCP record too late, and other irregularities, in resolvconf
+ interface-order
Revision history for this message
Kevin Otte (nivex) wrote :

My apologies for the delay in responding. Pesky life and all that.

The proposed interface-order in #11 does work for my particular case. I do have some thoughts on the bigger picture though.

> eth*([^.]).inet6
> eth*([^.]).inet
> eth*([^.]).ip6.@(dhclient|dhcpcd|pump|udhcpc)
> eth*([^.]).@(dhclient|dhcpcd|pump|udhcpc)

In the case of static IPv4 but automatic IPv6, this will still result in the IPv4 taking precedence. eg:

---
iface eth0 inet static
    ...
    dns-nameservers 1.2.3.4

iface eth0 inet6 auto
    dhcp 1
--

Would produce a resolv.conf with:
--
nameserver 1.2.3.4
nameserver 2001:db8:1234::1
--

I propose that the order list all of the IPv6 items before the IPv4.

eth*([^.]).inet6
eth*([^.]).ip6.@(dhclient|dhcpcd|pump|udhcpc)
eth*([^.]).inet
eth*([^.]).@(dhclient|dhcpcd|pump|udhcpc)

Like you I'm on the fence about switching the static vs dynamic order. Some of our more learned colleagues may need to chime in here.

Revision history for this message
Thomas Hood (jdthood) wrote :

> In the case of static IPv4 but automatic IPv6, this will still result in the IPv4 taking precedence.
[...]
> I propose that the order list all of the IPv6 items before the IPv4.

Hmm, are there reasons for preferring either one over the other?

This may be one of those changes where the problems will only become apparent after a release.

Revision history for this message
Thomas Hood (jdthood) wrote :

If there are no further comments then I'll prepare Debian resolvconf 1.70 according to the proposal from #11.

Revision history for this message
Thomas Hood (jdthood) wrote :

@Kevin: On second thought I think your suggestion in comment #14 is right; I now propose to release Debian resolvconf 1.70 with the following. Comments still more than welcome, of course.

# interface-order(5)
lo.inet6
lo.inet
lo.@(dnsmasq|pdnsd)
lo.!(pdns|pdns-recursor)
lo
tun*
tap*
hso*
em+([0-9])?(_+([0-9]))*
p+([0-9])p+([0-9])?(_+([0-9]))*
eth*([^.]).inet6
eth*([^.]).ip6.@(dhclient|dhcpcd|pump|udhcpc)
eth*([^.]).inet
eth*([^.]).@(dhclient|dhcpcd|pump|udhcpc)
eth*
@(ath|wifi|wlan)*([^.]).inet6
@(ath|wifi|wlan)*([^.]).ip6.@(dhclient|dhcpcd|pump|udhcpc)
@(ath|wifi|wlan)*([^.]).inet
@(ath|wifi|wlan)*([^.]).@(dhclient|dhcpcd|pump|udhcpc)
@(ath|wifi|wlan)*
ppp*
*

Revision history for this message
Thomas Hood (jdthood) wrote :

Done in recently released Debian resolvconf 1.70.

Revision history for this message
Kevin Otte (nivex) wrote :

I just discovered another gotcha. The new interface-order in #17 doesn't handle bridge interfaces. I've added those above the eth* for the following new file:

# interface-order(5)
lo.inet6
lo.inet
lo.@(dnsmasq|pdnsd)
lo.!(pdns|pdns-recursor)
lo
tun*
tap*
hso*
em+([0-9])?(_+([0-9]))*
p+([0-9])p+([0-9])?(_+([0-9]))*
br*([^.]).inet6
br*([^.]).ip6.@(dhclient|dhcpcd|pump|udhcpc)
br*([^.]).inet
br*([^.]).@(dhclient|dhcpcd|pump|udhcpc)
br*
eth*([^.]).inet6
eth*([^.]).ip6.@(dhclient|dhcpcd|pump|udhcpc)
eth*([^.]).inet
eth*([^.]).@(dhclient|dhcpcd|pump|udhcpc)
eth*
@(ath|wifi|wlan)*([^.]).inet6
@(ath|wifi|wlan)*([^.]).ip6.@(dhclient|dhcpcd|pump|udhcpc)
@(ath|wifi|wlan)*([^.]).inet
@(ath|wifi|wlan)*([^.]).@(dhclient|dhcpcd|pump|udhcpc)
@(ath|wifi|wlan)*
ppp*
*

It seems to work OK, but I haven't checked for any fun corner cases.

Revision history for this message
Thomas Hood (jdthood) wrote :

The original problem was fixed in resolvconf 1.70 which has since been merged to Vivid.

Changed in resolvconf (Ubuntu):
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.