DEV Community

Vinetos
Vinetos

Posted on

Enabling IPv6 on FreeBSD with DHCPv6 in Stateful Mode

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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"
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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}
Enter fullscreen mode Exit fullscreen mode

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!

Do your career a favor. Join DEV. (The website you're on right now)

It takes one minute and it's free.

Get started

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Explore a sea of insights with this enlightening post, highly esteemed within the nurturing DEV Community. Coders of all stripes are invited to participate and contribute to our shared knowledge.

Expressing gratitude with a simple "thank you" can make a big impact. Leave your thanks in the comments!

On DEV, exchanging ideas smooths our way and strengthens our community bonds. Found this useful? A quick note of thanks to the author can mean a lot.

Okay