Assign ipv6 address to KVM guests on bridge mode

So with the notice from Mark, I will answer my own question.

Host setup:

Assign the IPv6 sub block to your virtual bridge, in my example:

Add

<ip family='ipv6' address='2607:beef:be:beef:1::' prefix='96'>

To /etc/libvirt/qemu/networks/default.xml, use virsh destroy and rebuild the virbr0 device, in my case it generated a virbr1 device.

Add ip6tables rule:

ip6tables -A FORWARD -m physdev --physdev-is-bridged -j ACCEPT

ip6tables -A FORWARD -i br0 -j ACCEPT

On the VM side:

Add the selected IPv6 Address to your configuration file:

IPV6INIT=yes
IPV6ADDR=2607:beef:be:beef:1::253:8/128

Restart your VM's network interface, it just works.

I guess that because the VM is connecting with outside world via virbr1 interface at host. The gateway on host is br0. With ip6tables rule it will all sort out.

I've compiled step by step guide in my blog, https://luxing.im/adding-ipv6-support-for-kvm-vms/


Your gateway is wrong in your guest.

Since you bridged your network connection, it is as if the VM is on the same subnet (LAN) as the host. Thus it needs to use the same gateway address as the host.