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!

Image of Timescale

Timescale – the developer's data platform for modern apps, built on PostgreSQL

Timescale Cloud is PostgreSQL optimized for speed, scale, and performance. Over 3 million IoT, AI, crypto, and dev tool apps are powered by Timescale. Try it free today! No credit card required.

Try free

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

Engage with a sea of insights in this enlightening article, highly esteemed within the encouraging DEV Community. Programmers of every skill level are invited to participate and enrich our shared knowledge.

A simple "thank you" can uplift someone's spirits. Express your appreciation in the comments section!

On DEV, sharing knowledge smooths our journey and strengthens our community bonds. Found this useful? A brief thank you to the author can mean a lot.

Okay