IPv6 addresses for OpenBSD vmm virtual machines

Last update: $Id: vmm-ipv6.md,v 1.1 2026/02/03 19:32:04 cvs Exp $

I am in the grateful situation that I have an ISP that serves me full dual stack IPv4 and IPv6 addresses for nearly a decade. All my personal servers have IPv6 addresses and so I want to have them for my local vmm(4) virtual machines as well. The setup is so easy that it took me a while to figure out how easy it actually is :)

I assume that you already have a working IPv6 address on your host machine. Given your router hands out addresses via SLAAC or DHCP6, OpenBSD will pick one by default unless you enabled IPv4 only.

Configuration on the host

All VMs are connected via virtual ethernet bridges and the relevant part in /etc/vm.conf looks as follows:

switch "my_switch" {
    interface veb0
}

vm "current" {
    disable
    memory 2048M
    owner xhr
    disk "/var/vm/obsd-vmm-2.qcow2" format qcow2
    interface { switch "my_switch" }
}

Note that all VMs have a IPv4 address. Since the Internet is not yet IPv6 only, you will need this for quite some time. To enable the veb bridge and connect a vport, you need the following hostname.if(5) files in /etc:

$ cat /etc/hostname.vport0
inet 10.23.5.1/24
up

$ cat /etc/hostname.veb0
add vport0
up

Getting an IPv6 prefix to delegate to the VMs

Note that the vport does not have an IPv6 address yet, this is a job for dhcp6leased(8) which requests a prefix via DHCPv6-PD from my local router. Create the following file in /etc and replace fxp0 with the name of the interfaced connected to the network where also your router is.

$ cat /etc/dhcp6leased.conf
request prefix delegation on fxp0 for { vport0 }

Once you enable and start dhcp6leased, you'll get a IPv6 prefix and address on vport0:

$ doas rcctl enable dhcp6leased
$ doas rcctl start dhcp6leased

$ doas ifconfig vport0
vport0: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
    lladdr fe:e1:ba:d0:6c:ca
    index 5 priority 0 llprio 3
    groups: vport
    inet6 fe80::fce1:baff:fed0:6cca%vport0 prefixlen 64 scopeid 0x5
    inet6 2001:1abc:cd37:edfe::1 prefixlen 64 pltime 3597 vltime 7197

Since that prefix will most likely change over night (at least German ISPs rotate IPv4 addresses and IPv6 prefixes every night), you cannot set static IPv6 addresses for the VMs. Fortunately, OpenBSD has rad(8) in the base system and the config is as simple as one line.

$ cat /etc/rad.conf
interface vport0

Now enable and start rad(8) with rcctl to serve addresses using the latest prefix.

Configuration on the virtual machine

Each VM has a default vio0 interface with a static IPv4 address and one in the range of the delegation coming from dhcp6leased via SLAAC. The hostname.if for the VM number 1 file in /etc looks as follows:

$ cat /etc/hostname.vio0
inet 10.23.5.101/24
inet6 autoconf

Since slaacd(8) is running by default you should either already have an IPv6 address or one after the next reboot. IPv6 should work now.

$ ping6 -c 1 cdn.openbsd.org
PING openbsd.map.fastlydns.net (2a04:4e42:8d::820): 56 data bytes
64 bytes from 2a04:4e42:8d::820: icmp_seq=0 hlim=59 time=15.879 ms

--- openbsd.map.fastlydns.net ping statistics ---
1 packets transmitted, 1 packets received, 0.0% packet loss
round-trip min/avg/max/std-dev = 15.879/15.879/15.879/0.000 ms