I recently got IPv6 running at home, with most devices including my iPhone happily get an IPv6 assigned. My NAS running FreeBSD13.2 currently only has an IPv4 assigned, so I’m going to configure IPv6 for it too.

I’m still new to IPv6. The way I have it setup on my router, running OPNsense, is to set the “Router Advertisements” to “Unmanaged” with DHCPv6 disabled. “Unmanaged” for SLAAC (A flag), and SLAAC stands for Stateless Address Autoconfiguration. In simple term, each client will pick its own IPv6 based on the route prefix advertised by the router. This is just a simplification, and you should not quote for me this.

Right now, I’m just gonna try to get the IPv6 via SLAAC on my FreeBSD server. I think for the long term, it might be better to statically assign an IPv6 for this server.

So how can we get this done on FreeBSD that doesn’t use systemd-networkd or NetworkManager? It could be very much simple.

According to this [1], I only need to add a line to /etc/rc.conf where em0 is the network device.

ifconfig_em0_ipv6="inet6 accept_rtadv"

For my server, the name of the network interface is bge0, so here is my actual configuration.

root@nas:~ # grep bge0 /etc/rc.conf
ifconfig_bge0="inet 192.168.1.112 netmask 255.255.255.0"
ifconfig_bge0_ipv6="inet6 accept_rtadv"

And here is the output of ifconfig bge0 before network service is restarted:

root@nas:~ # ifconfig bge0
bge0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        options=c019b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,TSO4,VLAN_HWTSO,LINKSTATE>
        ether 44:1e:a1:3c:ab:e8
        inet 192.168.1.112 netmask 0xffffff00 broadcast 192.168.1.255
        media: Ethernet autoselect (1000baseT <full-duplex>)
        status: active
        nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>

Next, let’s restart the network service.

root@nas:~ # service netif restart
...

Verifying the output. (Note, some bits of IPv6 are masked with x.)

root@nas:~ # ifconfig bge0
bge0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        options=c019b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,TSO4,VLAN_HWTSO,LINKSTATE>
        ether 44:1e:a1:3c:ab:e8
        inet 192.168.1.112 netmask 0xffffff00 broadcast 192.168.1.255
        inet6 fe80::461e:a1ff:fe3c:abe8%bge0 prefixlen 64 scopeid 0x1
        inet6 2403:xxxx:xxxx:0:xxxx:a1ff:fe3c:abe8 prefixlen 64 autoconf
        media: Ethernet autoselect (1000baseT <full-duplex>)
        status: active
        nd6 options=23<PERFORMNUD,ACCEPT_RTADV,AUTO_LINKLOCAL>

Finally, let’s very if I can ping google.

root@nas:~ # ping6 -c4 google.com
PING6(56=40+8+8 bytes) 2403:xxxx:xxxx:0:xxxx:a1ff:fe3c:abe8 --> 2404:6800:4006:811::200e
16 bytes from 2404:6800:4006:811::200e, icmp_seq=0 hlim=119 time=10.611 ms
16 bytes from 2404:6800:4006:811::200e, icmp_seq=1 hlim=119 time=10.304 ms
16 bytes from 2404:6800:4006:811::200e, icmp_seq=2 hlim=119 time=9.622 ms
16 bytes from 2404:6800:4006:811::200e, icmp_seq=3 hlim=119 time=10.333 ms

--- google.com ping6 statistics ---
4 packets transmitted, 4 packets received, 0.0% packet loss
round-trip min/avg/max/std-dev = 9.622/10.217/10.611/0.364 ms

This is pretty cool. As mentioned earlier, I will need to figure out how to manually set an IPv6 for this server instead of getting one via SLAAC in the future.

References: