Hello fellow !
Today, I’m excited to share a step-by-step guide on how to enable IPv6 on your FreeBSD instance using DHCPv6 in stateful mode.
This configuration will allow your system to automatically obtain both IPv4 and IPv6 addresses from a DHCP server.
Let’s dive right in!
Install dhcpcd
First, we need to install the dhcpcd package, which is a DHCP client daemon. To do this, open your terminal and run the following command:
pkg install net/dhcpcd
Configure dhcpcd
Next, we’ll configure dhcpcd
by adding some lines to its configuration file located at /usr/local/etc/dhcpcd.conf
.
We’ll add the hostname to the DHCP request and enable the IA_NA option, which requests a non-temporary address assignment. Additionally, we’ll disable the generation of stable private IPv6 addresses based on the DUID (DHCP Unique Identifier). :
cat >>/usr/local/etc/dhcpcd.conf << DHCP_CONF
hostname
ia_na 1
DHCP_CONF
sed -i '' -e 's/^slaac private/#slaac private/' /usr/local/etc/dhcpcd.conf
Edit rc.conf
Now, let’s edit the rc.conf
file to tell FreeBSD to use dhcpcd as the DHCP client and configure our network interfaces to use DHCP for both IPv4 and IPv6. Open /etc/rc.conf
in your favorite text editor and add the following lines:
dhclient_program="/usr/local/sbin/dhcpcd"
ifconfig_${ifdev}="DHCP"
ifconfig_${ifdev}_ipv6="DHCP"
Replace ${ifdev}
with the name of your network interface, such as em0
, igb0
, vetnet0
, etc.
Reboot
Finally, reboot your system to apply the changes:
shutdown -r now
Once your system comes back online, it should have obtained both IPv4 and IPv6 addresses via DHCP. You can verify this by running the following commands:
ifconfig ${ifdev}
Replace ${ifdev}
with your network interface name.
And that’s it! You’ve successfully enabled IPv6 on your FreeBSD instance using DHCPv6 in stateful mode. Happy networking!
Discover more from Coursity
Subscribe to get the latest posts sent to your email.