Linux – Why does an IPv6 route added before virtual machine is started not work

ipv6kvm-virtualizationlinuxping

I have an external server at Hetzner with Debian 7 and trying to setup KVM with IPv6 Routing (the same setup works for IPv4 without problems).

I have one Ubuntu Server VM with two interfaces which are in two different subnet. The first interface ist connected to the host via a bridge:

Host-eth0 <-- external bridge --> vnet0-VM-vnet1 <-- internal bridge

I configured the bridge to add a static route to the second subnet via the first VM interface:

ip -6 route add 2a01:4f8:X:Y:2::/80 via 2a01:4f8:X:Y:1::3 dev virbr_external

This adds the route entry BEFORE the VM is started. When I use ping6 from the host to the vnet1 interface (2::2) I get this error message:

ping: sendmsg: Network is down

When I don't add the route in the interfaces configuration and call it manually AFTER the VM is started, everything works.

So my question is why does route add for IPv6 addresses only work after the the VM is started?

Additional Configuration Details:

Host Interfaces

auto lo
iface lo inet6 loopback

auto eth0
iface eth0 inet6 static
    address 2a01:4f8:X:Y:0::2
    netmask 128
    gateway fe80::1

# Bridge between Host and VM
auto virbr_external
iface virbr_external inet6 static
    bridge_ports none
    bridge_stp off
    bridge_fd 0
    address 2a01:4f8:X:Y:1::2
    netmask 80

up ip -6 route add 2a01:4f8:X:Y:2::/80 via 2a01:4f8:X:Y:1::3 dev virbr_external

# Bridge between VM and other VMs
auto virbr_internal
iface virbr_internal inet6 manual
    bridge_ports none
    bridge_stp off
    bridge_fd 0

VM Interfaces

auto lo
iface lo inet6 loopback

auto eth0
iface eth0 inet6 static
    address 2a01:4f8:X:Y:1::3
    netmask 80
    gateway 2a01:4f8:X:Y:1::2

auto eth1
iface eth1 inet6 static
    address 2a01:4f8:X:Y:2::2
    netmask 80

Please tell me if you need more logs (before and after it works), I will gather it then.

Best Answer

Having the same problem here. Solution is to flush the IPV6 route cache after setting the route:

ip -6 route flush cache

Changing your interfaces section to:

...
auto virbr_external
iface virbr_external inet6 static
   bridge_ports none
   bridge_stp off
   bridge_fd 0
   address 2a01:4f8:X:Y:1::2
   netmask 80
   up ip -6 route add 2a01:4f8:X:Y:2::/80 via 2a01:4f8:X:Y:1::3 dev virbr_external
   up ip -6 route flush cache # Flush cache after setting route
   ...

fixes the issue on boot.