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

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

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

in debian wheezy I had to do something silly to get it to work.. sorry about the formatting, I don't really get this site's layout and it's late.

      auto lo
      iface lo inet loopback
      allow-hotplug eth0
      auto eth0 eth0:0 eth0:1 eth0:2
      iface eth0 inet static
      address 66.xxx.xxx.101
      netmask 255.255.255.0
      gateway 66.xxx.xxx.1

      iface eth0:0 inet static
      address 173.xxx.xxx.6
      netmask 255.255.255.0

      iface eth0:1 inet static
      address 192.xxx.xxx.180
      netmask 255.255.xxx.0

      iface eth0 inet6 static
      address fe80::xxxx:xxxx:xxxx:f48e
      netmask 64
      gateway fe80::1

      iface eth0:0 inet6 static
      address 2600:xxx::f03c:xxx:xxx:f48e
      netmask 64

      iface eth0:1 inet6 static
      address 2600:xxx:xxx:007a::1
      netmask 64

      iface eth0:2 inet6 static
      address 2600:xxx:xxx:007a::2
      netmask 64

this resulted in the following:

      eth0      Link encap:Ethernet  HWaddr bogus:mac
      inet addr:66.xxx.xxx.101  Bcast:66.xxx.xxx.255  Mask:255.255.255.0
      inet6 addr: 2600:xxx::f03c:xxx:xxx:f48e/64 Scope:Global
      inet6 addr: fe80::f03c:91ff:feae:f48e/64 Scope:Link
      inet6 addr: 2600:xxx:xxx:7a::2/64 Scope:Global
      inet6 addr: 2600:xxx:xxx:7a::1/64 Scope:Global
      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
      RX packets:37908 errors:0 dropped:0 overruns:0 frame:0
      TX packets:30834 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:1000
      RX bytes:3201392 (3.0 MiB)  TX bytes:3735827 (3.5 MiB)

      eth0:0    Link encap:Ethernet  HWaddr bogus:mac
      inet addr:173.xxx.xxx.6  Bcast:173.xxx.xxx.255  Mask:255.255.255.0
      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

      eth0:1    Link encap:Ethernet  HWaddr bogus:mac
      inet addr:192.xxx.xxx.180  Bcast:192.xxx.xxx.255  Mask:255.255.xxx.0
      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

iproute2 is supposed to support declaring all of these (ipv4 at least) under eth0 instead of eth0:0...etc but that didn't work.. and even though I declared eth0:0 etc for ipv6 those all showed up under eth0 whereas they definitely didn't work when declared as eth0 specifically.