Debian Wheezy IPv6 isn’t configured with ifup post-up hook

configurationdebian-wheezyipv6

We recently set up a server on Debian Wheezy Beta 3 (x86_64) which has a native IPv6 connection.

We configured the eth0 interface to get the IPv6 configuration through some post-up hook commands in /etc/network/interfaces. The result is, that after the booting the system up, there is only IPv4 and an auto-configured link-local IPv6 address configured on the interface, as if the command has never been executed.

When we additionally place the commands after the call to ifup -a inside the /etc/init.d/networking init script, everything works as expected and we have a fully configured interface after booting up.

This is quite an ugly way to configure the interface. What are we doing wrong with the ifup post-up hooks? Or is this a bug?

Update: One additional fact is that I'm using a Dropbear SSH server to enable me to unlock my LUKS encrypted root file system. The Linux kernel is therefore given an IP address through the GRUB bootloader. That could mean that the IPv6 configuration is not done because eth0 is already up. I then tried to put an ifdown eth0 before ifup -a line in the /etc/init.d/networking script. It didn't change anything. Here an example of how it looked like:

ifdown eth0
if ifup -a $exclusions $verbose && ifup_hotplug $exclusions $verbose

Update: I set up a little script as post-up hook which configures the interface and writes the output to a log file. The result was that the log file was never written, which means the post-up hook wasn't called at all.

The section from /etc/network/interfaces looks like this (IP-addresses changed):

allow-hotplug eth0
iface eth0 inet static
        address 1.2.3.1
        netmask 255.255.255.192
        network 1.2.3.0
        broadcast 1.2.3.63
        gateway 1.2.3.62
        dns-nameservers 8.8.8.8
        dns-search mydomain.tld
        post-up ip -6 addr add 2001:db8:100:3022::2 dev eth0
        post-up ip -6 route add fe80::1 dev eth0
        post-up ip -6 route add default via fe80::1 dev eth0

I also tried it in this alternative way:

auto eth0
iface eth0 inet static
        address 1.2.3.1
        netmask 255.255.255.192
        network 1.2.3.0
        broadcast 1.2.3.63
        gateway 1.2.3.62
        dns-nameservers 8.8.8.8
        dns-search mydomain.tld

iface eth0 inet6 static
        address 2001:db8:100:3022::2
        netmask 64
        gateway fe80::1

What we added to /etc/init.d/networking:

…
case "$1" in
start)
        process_options
        check_ifstate

        if [ "$CONFIGURE_INTERFACES" = no ]
        then
            log_action_msg "Not configuring network interfaces, see /etc/default/networking"
            exit 0
        fi
        set -f
        exclusions=$(process_exclusions)
        log_action_begin_msg "Configuring network interfaces"
        if ifup -a $exclusions $verbose && ifup_hotplug $exclusions $verbose
        then
            # Our additions
            ip -6 addr add 2001:db8:100:3022::2 dev eth0
            ip -6 route add fe80::1 dev eth0
            ip -6 route add default via fe80::1 dev eth0

            log_action_end_msg $?
        else
            log_action_end_msg $?
        fi
        ;;
…

Update: The output of ip -6 address show eth0 after booting up is:

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qlen 1000
    inet6 fe80::abcd:abcd:abcd:abc/64 scope link 
       valid_lft forever preferred_lft forever

Best Answer

I had the same issue that IPv6 configuration would fail when I would pass the ip parameter to the kernel. The problem is that the networking scripts try to add an IP address to the eth0 interface which is already there. This will of course fail and so further configuration is stopped.

The easiest solution was to simply remove the IPv4 part from /etc/network/interfaces since it's already configured through the ip parameter anyway:

auto eth0
iface eth0 inet6 static
        address 2001:db8:100:3022::2
        netmask 64
        gateway fe80::1