Home / Articles

IPv6 configuration on OpenBSD

2023-04-13T12:57:57.804Z.

This document describes the configuration of IPv6 address on OpenBSD 7.3.

IPv6 configuration via SLAAC

OpenBSD 7.3 base system comes with slaacd(8) and is enabled by default. Add the following to the interface configuration file (e.g. /etc/hostname.vio0):


inet6 autoconf

To apply the configurations, run:


# Change the interface name accordingly.
sh /etc/netstart vio0

IPv6 static address configuration

Some ISPs or VPS service providers (e.g. OpenBSD Amsterdam, ConoHa) assign a /64 address to the computer with information like gateway. Assume your ISP or VPS service provider assign the IPv6 address 2606:2800:220:1::1946/64 and gateway at 2606:2800:220:1::1, add the following to the interface configuration file (e.g. /etc/hostname.vio0):


inet6 2606:2800:220:1::1946 64
!route add -inet6 default 2606:2800:220:1::1

To apply the configurations, run:


# Change the interface name accordingly.
sh /etc/netstart vio0

IPv6 configuration via DHCPv6

Some ISPs or VPS service providers assign a /64 address to the computer using DHCPv6. OpenBSD 7.3 does not have DHCPv6 client in base system. A third-party package dhcpcd(8) can be installed to configure IPv6 address:


pkg_add dhcpcd

Configure dhcpcd(8) by putting a configuration file at /etc/dhcpcd.conf. Assume only IPv6 address has to be configured on the interface vio0, add the configuration file:


# Inform the DHCP server of our hostname for DDNS.
hostname

# Use the same DUID + IAID as set in DHCPv6 for DHCPv4 ClientID as per RFC4361.
# Some non-RFC compliant DHCP servers do not reply with this set.
# In this case, comment out duid and enable clientid above.
duid

# Persist interface configuration when dhcpcd exits.
persistent

# vendorclassid is set to blank to avoid sending the default of
# dhcpcd-<version>:<os>:<machine>:<platform>
vendorclassid

# Respect the network MTU. This is applied to DHCP routes.
option interface_mtu

# Rapid commit support.
# Safe to enable by default because it requires the equivalent option set
# on the server to actually work.
option rapid_commit

# A ServerID is required by RFC2131.
require dhcp_server_identifier

# generate Stable Private IPv6 Addresses based from the DUID
slaac private

# Apply IPv6 configurations only.
ipv6only

# Configuure specific interfaces only.
allowinterfaces vio0

Enable and start dhcpcd(8):


rcctl enable dhcpcd
rcctl start dhcpcd

Verification

Use ifconfig(8) to check the IPv6 address assigned to the network interface and route(8) to check the routing tables.

To check if the computer can reach the Internet over IPv6, run:


ping6 -c 3 example.com

The output should be similar to the following:


PING example.com (2606:2800:220:1:248:1893:25c8:1946): 56 data bytes
64 bytes from 2606:2800:220:1:248:1893:25c8:1946: icmp_seq=0 hlim=57 time=103.895 ms
64 bytes from 2606:2800:220:1:248:1893:25c8:1946: icmp_seq=1 hlim=57 time=103.952 ms
64 bytes from 2606:2800:220:1:248:1893:25c8:1946: icmp_seq=2 hlim=57 time=103.922 ms

--- example.com ping statistics ---
3 packets transmitted, 3 packets received, 0.0% packet loss
round-trip min/avg/max/std-dev = 103.895/103.923/103.952/0.024 ms

References