Disclosure up front: I run IPYE, a company that leases IP space. Most of this article is practical how-to; IPYE appears where a free /48, LOA, or ROA helps you try the work, with a short call to action at the end.

libvirt's default network gives guests private IPv4 addresses behind NAT. For IPv6 with your own prefix, there is a better mode: a routed network, where the host routes a /64 to a bridge and guests get global addresses with no translation at all. libvirt sets up the bridge, the router advertisements, and optional DHCPv6 for you. This article builds a routed libvirt network for KVM guests using a /64 from a free IPv6 /48 from IPYE. The examples use 2001:db8:100::/48, with guests on 2001:db8:100:d0::/64 and the /48 routed to the host.

Define the network

<network> <name>free48-routed</name> <forward mode='route'/> <bridge name='virbr6' stp='on' delay='0'/> <ip family='ipv6' address='2001:db8:100:d0::1' prefix='64'> <dhcp> <range start='2001:db8:100:d0::100' end='2001:db8:100:d0::1ff'/> </dhcp> </ip> </network> 

forward mode='route' means libvirt routes between the bridge and the host's other interfaces without NAT. The <ip> element gives the bridge the router address. With a <dhcp> range, libvirt runs dnsmasq to send router advertisements and serve stateful DHCPv6 from the range. Leave out the <dhcp> block and dnsmasq sends RAs only, so guests use SLAAC.

virsh net-define free48-routed.xml virsh net-start free48-routed virsh net-autostart free48-routed 

The accept_ra trap

When libvirt starts an IPv6 routed network, it enables IPv6 forwarding on the host. On Linux, forwarding normally makes the kernel ignore router advertisements. If the host learns its own default route from RAs on the uplink, that route will expire and the host drops off the network some minutes later.

libvirt checks for this and refuses to start the network, with an error about accept_ra, when it detects RA-learned routes. The fix is to keep accepting RAs on the uplink while forwarding:

echo 'net.ipv6.conf.eth0.accept_ra = 2' > /etc/sysctl.d/60-libvirt-ra.conf sysctl --system 

If the uplink has a static default route instead, nothing needs changing.

Attach guests

virt-install --name web1 --memory 2048 --vcpus 2 \ --disk size=20 --os-variant debian12 \ --network network=free48-routed \ --location https://deb.debian.org/debian/dists/bookworm/main/installer-amd64/ 

For an existing guest:

virsh attach-interface web1 network free48-routed --model virtio --config 

Inside the guest, a standard DHCPv6 or SLAAC configuration picks up an address in 2001:db8:100:d0::/64 and a default route via the bridge.

Pin addresses for servers with host entries in the network definition:

<dhcp> <range start='2001:db8:100:d0::100' end='2001:db8:100:d0::1ff'/> <host name='web1' ip='2001:db8:100:d0::10'/> </dhcp> 

For IPv6, libvirt matches hosts by name or by DHCP unique identifier, not by MAC address. Matching by the guest's hostname is usually the simplest choice.

Routing the /64 to the host

libvirt does not announce anything to your upstream. The /48, or at least this /64, must already be routed to the host. That happens through the provider's static route or your own BGP session on the host. Keep a blackhole route for the /48 on the host so traffic to unused parts does not loop:

ip -6 route add blackhole 2001:db8:100::/48 

The bridge's connected /64 is more specific and wins for guest traffic.

Firewalling guests

libvirt installs its own firewall rules for its networks. In routed mode, it allows traffic between the bridge and the outside, but your host firewall decides what really reaches guests. Add forward rules for each guest's published services, and keep ICMPv6 allowed so guests do not lose their gateway or path MTU discovery:

table inet guests { chain forward { type filter hook forward priority 10; policy drop; ct state established,related accept meta l4proto ipv6-icmp accept iifname "virbr6" accept oifname "virbr6" ip6 daddr 2001:db8:100:d0::10 tcp dport { 80, 443 } accept } } 

Recent libvirt versions can use nftables as their firewall backend. Check your version's documentation if your own rules and libvirt's appear to conflict.

Verify

virsh net-dumpxml free48-routed ip -6 addr show virbr6 ip -6 route show 2001:db8:100:d0::/64 

From outside your network, ping a guest's address. If the host answers but the guest does not, check the forward chain and the guest's own firewall, in that order.

Upstream requirements

The /48 reaching your host is what makes all this work. Your provider will need the LOA from the IPYE customer area to route or accept it, and IPYE's ARIN or APNIC accounts take care of the ROA automatically.

Do this next

Request your free /48, define one routed libvirt network with a single /64, and fix accept_ra on the uplink before starting it. Questions: ipye@turnel.com.

About IPYE

IPYE (https://ipye.com) leases IPv4, IPv6 and ASN space with instant setup. Your first IPv6 /48 is free for the first year, a real allocation you can announce on your own ASN, with a LOA from the portal and the ROA created automatically. ASN and region changes apply automatically. IPv4 /24 to /22 leases include LOA, ROA and per-/24 rDNS; WHOIS is editable on IPv6 /44 and larger. Locations: Los Angeles, New York, Ashburn, Salt Lake City, London, Amsterdam, Frankfurt. Claim your free /48: https://my.ipye.com/products/ipv6-rental. Questions: ipye@turnel.com.

Disclosure: I run IPYE