# Configure an IPv6 Address

## Background Information

After assigning the primary IPv6 address, regardless of private or public IPv6, to your elastic compute instance, for some instances with certain images, you need to access the instance and configure the IPv6 to make it effective.

### IPv4 & IPv6 Dual Stack

You need manually configure the IPv6 address after assigning the primary IPv6 address for the following images:

* Windows
* FreeBSD 14
* Gentoo openrc

### IPv6 Single Stack

IPv6 addresses are not supported for the following images:

* Windows
* FreeBSD 14
* Gentoo openrc

If you allocate additional IPv6 addresses to your instances, you also need to configure them on instances. The rules are concluded as follows:

<table><thead><tr><th width="237">Image</th><th>IPv4 &#x26; IPv6 Dual Stack</th><th>IPv6 Single Stack</th></tr></thead><tbody><tr><td><ul><li>Ubuntu 20.04</li><li>Ubuntu 22.04</li><li>Ubuntu 24.04</li><li>Debian 12</li><li>Debian 11</li><li>Debian 10</li><li>Debian 9</li><li>openSUSE lead 15.6</li><li>Rocky base 9.3</li><li>CentOS 9</li><li>Fedora base 39 1.5</li><li>Alpine 3.19.1</li><li>ArchLinux</li><li>AlmaLinux 9.3</li></ul></td><td><ul><li><strong>Primary IPv6</strong><br>Effective by default. No manual configuration is required.</li><li><strong>Additional IPv6</strong><br>Manual configuration is required.</li></ul></td><td><ul><li><strong>Primary IPv6</strong><br>Effective by default. No manual configuration is required.</li><li><strong>Additional IPv6</strong><br>Manual configuration is required.</li></ul></td></tr><tr><td><ul><li>Windows</li><li>FreeBSD 14</li><li>Gentoo openrc</li></ul></td><td><ul><li><strong>Primary IPv6</strong><br>Manual configuration is required.</li><li><strong>Additional IPv6</strong><br>Manual configuration is required.</li></ul></td><td>IPv6 addresses are not supported.</td></tr></tbody></table>

## Prerequisites

Before configuring the IPv6 address, ensure the IPv6 service is enabled. Currently, you need to enable IPv6 service on the instance with FreeBSD 14 image.

See [**Enable IPv6 Service**](#enable-ipv6-service) for detailed steps.

## Procedures

### Enable IPv6 Service

You can enable IPv6 service on the instance with FreeBSD 14 image as follows:

1. Configure your network interface to use IPv6. Run the following command to modify the `/etc/rc.conf` configuration file.

   ```sh
   sudo vi /etc/rc.conf
   ```
2. Press `i` to enter edit mode. Add or update the following lines to enable IPv6 on your network interface.

   ```sh
   ipv6_activate_all_interfaces="YES"
   ```
3. Press `Esc` to exit edit mode. Type `:wq` and press `Enter` to save and exit.
4. Run the following command to restart your network and apply the configuration.

   <pre class="language-sh"><code class="lang-sh"><strong>/etc/netstart restart
   </strong></code></pre>

### Configure IPv6 Addresses

Configure the IPv6 addresses on your instances with the following images.

<details>

<summary>Debian 9, Debian 10, Debian 11</summary>

The assigned IPv6 address will take effect automatically but may be invalid after an instance reboot. Therefore, `cloud-init`'s ability to modify network interface files in the `/etc/network/interfaces.d` directory must be disabled.

In the following example, default network interface configuration file is: `/etc/cloud/cloud.cfg.d/99-disable-network-config.cfg`.

1. Execute the following command to open the configuration file of network interface.

   ```bash
   sudo vi /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg
   ```
2. Configure the following information, save and exit.

   ```bash
   network: {config: disabled}
   ```
3. Execute the following command to open the configuration file of network interface.

   ```bash
   sudo vi /etc/network/interfaces.d/50-cloud-init
   ```
4. For Debian 10 and Debian 11, append the following information at the end.

   ```
   iface ens1 inet6 dhcp
   ```

   After modification, save and exit.
5. For Debian 9, append the following information at the end.

   ```
   iface eth0 inet6 dhcp
   ```

   After modification, save and exit.
6. Run the following command to reboot your instance.

   ```bash
   sudo reboot
   ```

</details>

<details>

<summary>openSUSE lead 15.6</summary>

**Configure DHCPv6**

1. Open the network configuration file for your network interface (e.g., `eth0`).

   ```sh
   sudo nano /etc/sysconfig/network/ifcfg-eth0
   ```
2. Update the file with the following settings to enable DHCP for IPv6.

   ```sh
   codeBOOTPROTO='dhcp'
   LLADDR='52:54:00:13:50:20'
   STARTMODE='auto'
   ```
3. Reboot the system to apply the changes.

   ```sh
   sudo reboot
   ```

**Manually Configure an IPv6 Address**

1. Add the IPv6 address. Replace `2001:2:0:d38e:0:2::2` with your actual IPv6 address.

   ```sh
   sudo ip -6 addr add dev eth0 2001:2:0:d38e:0:2::2/64
   ```
2. Add the default IPv6 route. Replace `2001:2:0:d38e::1` with your actual IPv6 gateway.

   ```sh
   sudo ip -6 route add default via 2001:2:0:d38e::1
   ```

**Make the IPv6 Address Configuration Persistent**

1. Open the network configuration file for your network interface (e.g., `eth0`).

   ```sh
   sudo nano /etc/sysconfig/network/ifcfg-eth0
   ```
2. Modify the file to include both static IPv4 and IPv6 addresses.

   ```sh
   BOOTPROTO='static'
   LLADDR='52:54:00:c4:f9:2c'
   STARTMODE='auto'
   # Static IPv4 configuration
   IPADDR_0='10.1.1.2/24'
   # Static IPv6 configuration, use multiple lines for multiple addresses
   IPADDR_1='2001:2:0:d38e:0:2::2/64'
   ```
3. Open the routes configuration file.

   ```sh
   sudo nano /etc/sysconfig/network/routes
   ```
4. Add the default IPv4 and IPv6 routes.

   ```sh
   default 10.1.1.1
   default 2001:2:0:d38e::1
   ```

</details>

<details>

<summary>FreeBSD 14</summary>

{% hint style="info" %} <mark style="color:blue;">**Note**</mark>

[<mark style="color:purple;">Enable IPv6 service</mark>](#enable-ipv6-service) <mark style="color:blue;">first before configuration.</mark>
{% endhint %}

**Preliminary Steps**

1. Run the following command to open the network configuration file.

   ```sh
   sudo vi /etc/rc.conf
   ```
2. Add the following lines to enable IPv6 address control and network interfaces.

   ```sh
   ip6addrctl_policy="AUTO"
   ip6addrctl_enable="YES"
   ipv6_network_interface="auto"
   ipv6_activate_all_interface=YES
   ```

**Method 1: Configure DHCPv6**

1. Add the following lines to accept IPv6 router advertisements and specify the DHCP client.

   ```sh
   ifconfig_vtnet0_ipv6="inet6 accept_rtadv"
   dhclient_program="/usr/local/sbin/dual-dhclient"
   ```
2. Install the `dual-dhclient` package to handle DHCPv6.

   ```sh
   sudo pkg install dual-dhclient
   ```
3. Example configuration.

   Your `/etc/rc.conf` should look something like this.

   ```sh
   growfs_enable="YES"
   growfs_swap_size=0
   cloudinit_enable="YES"
   sshd_enable="YES"
   ifconfig_vtnet0="DHCP"
   hostname="host-1151000555997504712"
   ip6addrctl_policy="AUTO"
   ip6addrctl_enable="YES"
   ipv6_network_interface="auto"
   ipv6_activate_all_interface=YES
   ifconfig_vtnet0_ipv6="inet6 accept_rtadv"
   dhclient_program="/usr/local/sbin/dual-dhclient"
   ```
4. Reboot the system to apply the changes.

   ```sh
   sudo reboot
   ```

**Method 2: Manual Configure an IPv6 Address**

Replace the placeholders `<your_ipv6_address_1>`, `<your_ipv6_address_2>`, `<subnet_prefix_length>`, and `<subnet_gateway_ip>` with your actual network values.

1. Modify `/etc/rc.conf` for single IPv6 address.

   Add the following lines to manually set a single IPv6 address and default route.

   ```sh
   ifconfig_vtnet0_ipv6="inet6 <your_ipv6_address> prefixlen <subnet_prefix_length> accept_rtadv"
   ipv6_gateway_enable="YES"
   ipv6_defaultrouter="<subnet_gateway_ip>"
   ```
2. Modify `/etc/rc.conf` for multiple IPv6 addresses.

   Add the following lines to manually set multiple IPv6 addresses and default route.

   ```sh
   ifconfig_vtnet0_ipv6="inet6 <your_ipv6_address_1> prefixlen <subnet_prefix_length> accept_rtadv"
   ifconfig_vtnet0_ipv6_alias0="inet6 <your_ipv6_address_2> prefixlen <subnet_prefix_length>"
   ipv6_gateway_enable="YES"
   ipv6_defaultrouter="<subnet_gateway_ip>"
   ```
3. Example configuration.

   Your `/etc/rc.conf` should look something like this.

   ```sh
   growfs_enable="YES"
   growfs_swap_size=0
   cloudinit_enable="YES"
   sshd_enable="YES"
   ifconfig_vtnet0="DHCP"
   hostname="host-1151000555997504712"
   ip6addrctl_policy="AUTO"
   ip6addrctl_enable="YES"
   ipv6_network_interface="auto"
   ipv6_activate_all_interface=YES
   ifconfig_vtnet0_ipv6="inet6 2001:2:0:d38e:0:2::2 prefixlen 64 accept_rtadv"
   ipv6_gateway_enable="YES"
   ipv6_defaultrouter="2001:2:0:d38e::1"
   ```
4. Reboot the system to apply the changes.

   ```sh
   sudo reboot
   ```

</details>

<details>

<summary>Ubuntu 20.04, Ubuntu 22.04, Ubuntu 24.04</summary>

The network configuration is typically managed by Netplan.

1. Netplan configuration files are located in `/etc/netplan/`. The file might be named something like `01-netcfg.yaml` or `50-cloud-init.yaml`. Run the following command to open the Netplan configuration file.

   ```sh
   sudo vi /etc/netplan/01-netcfg.yaml
   ```
2. Add or modify the configuration. Here is an example.

   ```yaml
   network:
     version: 2
     ethernets:
       eth0:
         dhcp4: no
         dhcp6: no
         addresses:
           - 2001:db8::1/64
           - 2001:db8::2/64
         gateway6: 2001:db8::ff
         nameservers:
           addresses:
             - 2001:4860:4860::8888
             - 2001:4860:4860::8844
   ```
3. Apply the Netplan configuration with the following command.

   ```sh
   sudo netplan apply
   ```

</details>

<details>

<summary>Debian 12</summary>

The network configuration is typically managed through the `/etc/network/interfaces` file or through NetworkManager.

**Edit the Configuration File**

1. Run the following command to open the network configuration file.

   ```sh
   sudo vi /etc/network/interfaces
   ```
2. Add or modify the configuration. Here is an example.

   ```ini
   auto eth0
   iface eth0 inet static
       address 192.0.2.1
       netmask 255.255.255.0
       gateway 192.0.2.254

   iface eth0 inet6 static
       address 2001:db8::1
       netmask 64
       gateway 2001:db8::ff
       up /sbin/ip -6 addr add 2001:db8::2/64 dev eth0
   ```
3. Restart the networking service to apply the changes.

   ```sh
   sudo systemctl restart networking
   ```

**Use NetworkManager**

You can use `nmcli` or the graphical NetworkManager tool to configure the network settings.

Here is an example for `nmcli`.

```sh
nmcli connection modify eth0 ipv6.method manual ipv6.addresses 2001:db8::1/64 ipv6.gateway 2001:db8::ff ipv6.dns "2001:4860:4860::8888,2001:4860:4860::8844"
nmcli connection up eth0
```

</details>

<details>

<summary>Rocky base 9.3</summary>

**Configure DHCPv6**

1. Run the following command to open the network interface configuration file. Replace `eth0` with your actual network interface value.

   ```sh
   sudo vi /etc/sysconfig/network-scripts/ifcfg-eth0
   ```
2. Press `i` to enter insert mode, and add the following configuration.

   ```ini
   IPV6INIT=yes
   DHCPV6C=yes
   ```
3. Press `Esc` to exit edit mode. Type `:wq` and press `Enter` to save and exit.
4. Restart the instance to apply the configuration changes.

   ```sh
   sudo reboot
   ```

</details>

<details>

<summary>CentOS 9</summary>

**Configure DHCPv6**

1. Run the following command to open the network interface configuration file. Replace `eth0` with your actual network interface value.

   ```sh
   sudo vi /etc/sysconfig/network-scripts/ifcfg-eth0
   ```
2. Press `i` to enter insert mode, and add the following configuration.

   ```ini
   IPV6INIT=yes
   DHCPV6C=yes
   ```
3. Press `Esc` to exit edit mode. Type `:wq` and press `Enter` to save and exit.
4. Restart the instance to apply the configuration changes.

   ```sh
   sudo reboot
   ```

</details>

<details>

<summary>Fedora base 39 1.5</summary>

Modify the NetworkManager connection profile to configure IPv6 addresses.

**Configure DHCPv6**

1. Run the following command to open the `cloud-init-eth0.nmconnection` file. Replace `eth0` with your actual network interface identifier if necessary.

   ```sh
   sudo vi /etc/NetworkManager/system-connections/cloud-init-eth0.nmconnection
   ```
2. Make sure the following settings are present under the `[ipv6]` section.

   ```ini
   [ipv6]
   method=auto
   ```
3. Press `Esc` to exit edit mode. Type `:wq` and press `Enter` to save and exit.
4. Restart NetworkManager to apply the changes.

   ```sh
   sudo systemctl restart NetworkManager
   ```

**Manually Configure an IPv6 Address**

1. Run the following command to open the `cloud-init-eth0.nmconnection` file. Replace `eth0` with your actual network interface value.

   ```sh
   sudo vi /etc/NetworkManager/system-connections/cloud-init-eth0.nmconnection
   ```
2. Modify the `[ipv6]` section. Replace `eth0` with your actual network interface name and use your specific IPv6 address, prefix length, and gateway.

   ```ini
   [ipv6]
   method=manual
   addresses1=2001:db8::1/64
   gateway=2001:db8::ff
   dns=2001:4860:4860::8888;2001:4860:4860::8844;
   ```
3. Press `Esc` to exit edit mode. Type `:wq` and press `Enter` to save and exit.
4. Restart NetworkManager to apply the IPv6 configuration.

   ```sh
   sudo systemctl restart NetworkManager
   ```

</details>

<details>

<summary>Alpine 3.19.1</summary>

Use the `dhcpcd` package to configure DHCPv6.

1. Install the `dhcpcd` package, which is a DHCP client daemon.

   ```sh
   apk add dhcpcd
   ```
2. Enable `dhcpcd` to start at boot and then start the service.

   ```sh
   rc-update add dhcpcd default
   rc-service dhcpcd start
   ```
3. Reboot the system to apply the configuration changes.

   <pre class="language-sh"><code class="lang-sh"><strong>sudo reboot
   </strong></code></pre>

</details>

<details>

<summary>ArchLinux</summary>

**Configure DHCPv6**

1. By default, `cloud-init` generates a DHCP configuration file located at `/etc/systemd/network/10-cloud-init-eth0.network`. Open this file to verify the configuration.

   ```sh
   sudo vi /etc/systemd/network/10-cloud-init-eth0.network
   ```
2. Make sure the following lines are present under the `[Network]` section.

   ```ini
   [Match]
   Name=eth0

   [Network]
   DHCP=yes
   ```
3. Press `Esc` to exit edit mode. Type `:wq` and press `Enter` to save and exit.
4. Restart the systemd-networkd service to apply the configuration.

   ```sh
   sudo systemctl restart systemd-networkd
   ```

**Configure an IPv6 Address**

1. Run the following command to create or edit `/etc/systemd/network` file.

   ```sh
   sudo vi /etc/systemd/network/10-static-eth0.network
   ```
2. Add the following lines to the file. Replace `eth0` with your actual network interface name and use your specific IPv6 address, prefix length, and gateway.

   ```ini
   [Match]
   Name=eth0

   [Network]
   Address=2001:db8::1/64
   Gateway=2001:db8::ff
   DNS=2001:4860:4860::8888 2001:4860:4860::8844
   ```
3. Press `Esc` to exit edit mode. Type `:wq` and press `Enter` to save and exit.
4. Restart the systemd-networkd service to apply the static IPv6 configuration.

   ```sh
   sudo systemctl restart systemd-networkd
   ```

</details>

<details>

<summary>AlmaLinux 9.3</summary>

**Configure DHCPv6**

1. Run the following command to open the network interface configuration file. Replace `eth0` with your actual network interface value.

   ```sh
   sudo vi /etc/sysconfig/network-scripts/ifcfg-eth0
   ```
2. Press `i` to enter insert mode, and add the following configuration.

   ```ini
   IPV6INIT=yes
   DHCPV6C=yes
   ```
3. Press `Esc` to exit edit mode. Type `:wq` and press `Enter` to save and exit.
4. Restart the instance to apply the configuration changes.

   ```sh
   sudo reboot
   ```

</details>

<details>

<summary>Gentoo openrc</summary>

Gentoo openrc supports DHCPv6 by default through configuration files located in `/etc/init.d/net.*`. You can manually create the `/etc/conf.d/net` file to configure IPv6 addresses.

**Configure DHCPv6**

1. Run the following command to create or edit `/etc/conf.d/net` file.

   ```sh
   sudo vi /etc/conf.d/net
   ```
2. Add configuration for DHCP.

   ```ini
   config_eth0="dhcp"
   ```

**Manual Configure an IPv6 Address**

1. Run the following command to create or edit `/etc/conf.d/net` file.

   ```sh
   sudo vi /etc/conf.d/net
   ```
2. Add Configuration for IPv6. Replace with your actual network values.

   ```ini
   config_eth0="2001:db8::1/64"
   routes_eth0="default via 2001:db8::ff"
   dns_servers_eth0="2001:4860:4860::8888 2001:4860:4860::8844"
   ```
3. Restart the network service.

   ```bash
   sudo /etc/init.d/net.eth0 restart
   ```

</details>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.console.zenlayer.com/welcome/elastic-compute/get-started/manage-instances/configure-an-ipv6-address.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
