How Do I Configure an ECS to Dynamically Acquire IPv6 Addresses?
Scenarios
IPv6 addresses are used to deal with the problem of IPv4 address exhaustion. If an ECS uses an IPv4 address, the ECS can run in dual-stack mode after IPv6 is enabled. That is, the ECS has two IP addresses: an IPv4 address and an IPv6 address. Both IP addresses can be used to access the intranet or public network.
Some ECSs created according to the network environment requirements in Constraints cannot dynamically acquire IPv6 addresses. If an ECS is created from a public image, the following requirements must be met:
- By default, dynamic IPv6 address assignment is enabled for Windows public images. You do not need to configure it. The operations in Windows are for your reference only.
- Before enabling dynamic IPv6 address assignment for a Linux public image, check whether IPv6 is supported and then check whether dynamic IPv6 address assignment has been enabled. Currently, all Linux public images support IPv6, and dynamic IPv6 address assignment is enabled for the Ubuntu 16 OS by default. That is, you do not need to configure dynamic IPv6 address assignment for the Ubuntu 16 OS. For other Linux public images, you need to enable this function.
In addition, this document provides the methods for both automatically and manually configuring IPv6 addresses (see Linux (Automatic Configuration of IPv6) and Linux (Manual Configuration of IPv6)). The automatic configuration is recommended.
Constraints
- Ensure that IPv6 has been enabled on the subnet where the ECS works.
For details about how to enable IPv6 on a subnet, see IPv4 and IPv6 Dual-Stack Network.
- Ensure that Self-assigned IPv6 address is selected during ECS creation.
Figure 1 Self-assigned IPv6 address
Only the following ECSs support IPv4/IPv6 dual stack:- ECSs with the flavor sn3 in AZ2 of the CN North-Beijing4 region
- ECSs with the flavor c3 or m3 in AZ1 of the CN East-Shanghai1 region
- ECSs with the flavor c3 in AZ2 of the CN East-Shanghai1 region
- After the ECS is started, hot-swappable NICs cannot automatically acquire IPv6 addresses.
- Only ECSs can work in the dual-stack network. BMSs do not support this function.
- Only one IPv6 address can be bound to each NIC.
Windows
- Run the following command in the CMD window to check whether IPv6 is enabled for the ECS:
ipconfig
- If IPv6 is enabled, an IPv6 address is displayed.
Figure 2 Querying the IPv6 address
- If only an IPv6 local link address is displayed, IPv6 addresses cannot be dynamically acquired. Go to 2.
Figure 3 IPv6 local link address
- If IPv6 is disabled, no IPv6 address is displayed. Go to 3.
Figure 4 IPv6 disabled
By default, dynamic IPv6 address assignment is enabled for Windows public images (case 1). No special configuration is required.
- If IPv6 is enabled, an IPv6 address is displayed.
- Configure dynamic IPv6 address assignment. (Windows Server 2008 is used as an example.)
- Choose Start > Control Panel.
- Click Network and Sharing Center.
- Click Change adapter settings.
- Right-click Local Connection and choose Properties.
- Select Internet Protocol Version 6 (TCP/IPv6) and click OK.
Figure 5 Configuring dynamic IPv6 address assignment
- Perform 1 to check whether dynamic IPv6 address assignment is enabled.
- Enable and configure IPv6.
- Choose Start > Control Panel > Network Connection > Local Connection.
- Select Properties, select the following options, and click Install.
Figure 6 Enabling and configuring IPv6
- Select Protocol and click Add.
Figure 7 Adding the protocol
- Select Microsoft TCP/IP Version 6 and click OK.
Figure 8 Network protocols
- (Optional) Run the following commands depending on your OS.
- If the ECS runs Windows Server 2008, run the following command in PowerShell or CMD:
netsh interface ipv6 set global randomizeidentifiers=disable
Disable the local connection and then enable it again.
To disable the local connection, choose Start > Control Panel > Network and Internet > Network and Sharing Center > Change Adapter Options. Right-click the local connection and choose Disable from the shortcut menu.
To enable the local connection, choose Start > Control Panel > Network and Internet > Network and Sharing Center > Change Adapter Options. Right-click the local connection and choose Enable from the shortcut menu.
- If the ECS runs Windows Server 2012/2016, run the following command in PowerShell:
- If the ECS runs Windows Server 2008, run the following command in PowerShell or CMD:
- Perform 1 to check whether dynamic IPv6 address assignment is enabled.
Linux (Automatic Configuration of IPv6)
The ipv6-setup-xxx tool can be used to enable Linux OSs to automatically acquire IPv6 addresses. xxx indicates a tool, which can be rhel or debian.
You can also enable IPv6 by following the instructions in Linux (Manual Configuration of IPv6).
- When the ipv6-setup-xxx tool is running, the network service is automatically restarted. As a result, the network is temporarily unavailable.
- After automatic IPv6 address assignment is configured on an ECS running CentOS 6.x or Debian, the ECS will be created as a private image. When this image is used to create an ECS in an environment that IPv6 is unavailable, the ECS may start slow because acquiring an IPv6 address times out. Before creating the private image, you can set the timeout duration for acquiring IPv6 addresses to 30s by referring to Setting the Timeout Duration for IPv6 Address Acquisition.
- Run the following command to check whether IPv6 is enabled for the ECS:
ip addr
- If IPv6 is disabled, only an IPv4 address is displayed. Enable IPv6 by referring to 2.
Figure 9 IPv6 disable
- If IPv6 is enabled, you can see an LLA address (starting with fe80).
Figure 10 IPv6 enabled
- If IPv6 is enabled and an IPv6 address is acquired, the following is displayed:
Figure 11 IPv6 enabled and an IPv6 address acquired
- If IPv6 is disabled, only an IPv4 address is displayed. Enable IPv6 by referring to 2.
- Enable IPv6 for the Linux ECS.
- Run the following command to check whether the kernel supports IPv6:
- If a command output is displayed, the kernel supports IPv6.
- If no information is displayed, the kernel does not support IPv6. In this case, go to 2.b to load the IPv6 module.
- Run the following command to load the IPv6 module:
- Add the following content to the /etc/sysctl.conf file:
net.ipv6.conf.all.disable_ipv6=0
- Save the configuration and exit. Then, run the following command to load the configuration:
- Run the following command to check whether the kernel supports IPv6:
- Enable automatic configuration of IPv6.
- Download the required ipv6-setup-rhel or ipv6-setup-debian and upload it to the target ECS.
ipv6-setup-xxx adds or modifies the configuration file of the NIC, adds the configuration information for dynamically acquiring IPv6 addresses, and restarts the NIC or network service. Table 1 lists the download paths of ipv6-setup-rhel and ipv6-setup-debian.
Table 1 ipv6-setup-rhel and ipv6-setup-debian download paths Series
Release Version
How to Obtain
RHEL
- CentOS 6/7
- EulerOS 2.2/2.3
- Fedora 25
https://ecs-instance-driver.obs.cn-north-1.myhuaweicloud.com/ipv6/ipv6-setup-rhel
Debian
- Ubuntu 16/18
- Debian 8/9
https://ecs-instance-driver.obs.cn-north-1.myhuaweicloud.com/ipv6/ipv6-setup-debian
- Run the following command to assign execution permissions to ipv6-setup-xxx:
chmod +x ipv6-setup-xxx
- Run the following command to enable dynamic IPv6 address assignment for a NIC:
Example:
./ipv6-setup-xxx --dev eth0
- To enable dynamic IPv6 address assignment for all NICs, run the ./ipv6-setup-xxx command.
- To learn how to use ipv6-setup-xxx, run the ./ipv6-setup-xxx --help command.
- Download the required ipv6-setup-rhel or ipv6-setup-debian and upload it to the target ECS.
Linux (Manual Configuration of IPv6)
After automatic IPv6 address assignment is configured on an ECS running CentOS 6.x or Debian, the ECS will be created as a private image. When this image is used to create an ECS in an environment that IPv6 is unavailable, the ECS may start slow because acquiring an IPv6 address times out. Before creating the private image, you can set the timeout duration for acquiring IPv6 addresses to 30s by referring to Setting the Timeout Duration for IPv6 Address Acquisition.
- Run the following command to check whether IPv6 is enabled for the ECS:
ip addr
- If IPv6 is disabled, only an IPv4 address is displayed. Enable IPv6 by referring to 2.
Figure 12 IPv6 disabled
- If IPv6 is enabled, you can see an LLA address (starting with fe80).
Figure 13 IPv6 enabled
- If IPv6 is enabled and an IPv6 address is acquired, the following is displayed:
Figure 14 IPv6 enabled and an IPv6 address acquired
- If IPv6 is disabled, only an IPv4 address is displayed. Enable IPv6 by referring to 2.
- Enable IPv6 for the Linux ECS.
- Run the following command to check whether the kernel supports IPv6:
- If a command output is displayed, the kernel supports IPv6.
- If no information is displayed, the kernel does not support IPv6. In this case, go to 2.b to load the IPv6 module.
- Run the following command to load the IPv6 module:
- Add the following content to the /etc/sysctl.conf file:
net.ipv6.conf.all.disable_ipv6=0
- Save the configuration and exit. Then, run the following command to load the configuration:
- Run the following command to check whether the kernel supports IPv6:
- Enable IPv6 manually. The procedure varies depending on the OS.
- Enable dynamic IPv6 address assignment for an ECS running Ubuntu.
For Ubuntu 18.04, perform the following steps. For Ubuntu 16.04, skip these steps because IPv6 is enabled by default.
- Add the following content below iface eth0 inet dhcp in the /etc/network/interface configuration file:
iface eth0 inet6 dhcp
- (Optional) Set the IPv6 LLA generation mode of the NIC to EUI64.
nmcli con modify "Wired connection 1" ipv6.addr-gen-mode eui64
- Run the following commands to restart the network service:
ifup eth0
- Add the following content below iface eth0 inet dhcp in the /etc/network/interface configuration file:
- Enable dynamic IPv6 address assignment for the ECS running Debian.
- Add the following content to the /etc/network/interfaces file:
auto lo iface lo inet loopback auto eth0 iface eth0 inet dhcp iface eth0 inet6 dhcp pre-up sleep 3 - If there are multiple NICs, add the NIC configurations in the /etc/network/interfaces file. The following uses eth1 as an example:
auto eth1 iface eth1 inet dhcp iface eth1 inet6 dhcp pre-up sleep 3 - Run the following command to restart the network service:
If an IPv6 address cannot be acquired after the NICs are brought down and up, you can run this command to restart the network.
- Perform 1 to check whether dynamic IPv6 address assignment is enabled.
- Add the following content to the /etc/network/interfaces file:
- Enable dynamic IPv6 address assignment for an ECS running CentOS, EulerOS, or Fedora.
- Open the primary NIC configuration file /etc/sysconfig/network-scripts/ifcfg-eth0.
Add the following configuration items to the file:
IPV6INIT=yes DHCPV6C=yes
- Edit the /etc/sysconfig/network file to add or modify the following line:
NETWORKING_IPV6=yes
- For the NICs of an ECS running CentOS 6, you need to edit the corresponding configuration files. For example, if the NIC is eth1, you need to edit /etc/sysconfig/network-scripts/ifcfg-eth1.
Add the following configuration items to the file:
IPV6INIT=yes DHCPV6C=yes
In CentOS 6.3, dhcpv6-client requests are filtered by ip6tables by default. Therefore, modify the ifcfg-eth* file and add an ip6tables rule that allows the dhcpv6-client request for CentOS 6.3. To do so, perform the following operations:
- (Optional) For CentOS 7, change the IPv6 LLA address mode of the extension NIC to EUI64.
- Run the following command to query the NIC information:
Figure 16 Viewing NIC information
- Run the following command to change the IPv6 Link Local Address (LLA) mode of eth1 to EUI64:
nmcli con modify "Wired connection 1" ipv6.addr-gen-mode eui64
- Run the following commands to bring eth1 down and up:
ifup eth1
- Run the following command to query the NIC information:
- Restart the network.
- Perform 1 to check whether dynamic IPv6 address assignment is enabled.
- Open the primary NIC configuration file /etc/sysconfig/network-scripts/ifcfg-eth0.
- Enable dynamic IPv6 address assignment for the ECS running SUSE, openSUSE, or CoreOS.
SUSE 11 SP4 does not support dynamic IPv6 address assignment.
No special configuration is required for SUSE 12 SP1 or SUSE 12 SP2.
No special configuration is required for openSUSE 13.2 or openSUSE 42.2.
No special configuration is required for CoreOS 10.10.5.
- Enable dynamic IPv6 address assignment for an ECS running Ubuntu.
Setting the Timeout Duration for IPv6 Address Acquisition
After automatic IPv6 address assignment is configured on an ECS running CentOS 6.x or Debian, the ECS will be created as a private image. When this image is used to create an ECS in an environment that IPv6 is unavailable, the ECS may start slow because acquiring an IPv6 address times out. Before creating the private image, you can set the timeout duration for acquiring IPv6 addresses to 30s by following the instructions in this section.
- CentOS 6.x:
- Run the following command to edit the dhclient.conf file:
vi /etc/dhcp/dhclient.conf
- Press i to enter editing mode and add the timeout attribute to the file.
timeout 30;
- Enter :wq to save the settings and exit.
- Run the following command to edit the dhclient.conf file:
- Debian 7.5:
- Run the following command to edit the networking file:
vi /etc/init.d/networking
- Press i to enter editing mode and add the timeout attribute.
Figure 17 Modification 1
Figure 18 Modification 2
- Run the following command to edit the networking file:
- Debian 8.2.0/8.8.0
- Run the following command to edit the network-pre.conf file:
vi /lib/systemd/system/networking.service.d/network-pre.conf
- Press i to enter editing mode and add the timeout attribute to the file.
[Service] TimeoutStartSec=30
- Run the following command to edit the network-pre.conf file:
- Debian 9.0
- Run the following command to edit the networking.service file:
vi /etc/system/system/network-online.target.wants/networking.service
- Press i to enter editing mode and change TimeoutStartSec=5min to TimeoutStartSec=30.
- Run the following command to edit the networking.service file:

Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.