How Do I Configure an ECS to Use DHCPv6?
Scenarios
IPv6 addresses are used to deal with IPv4 address exhaustion. If an ECS uses an IPv4 address, the ECS can run in dual-stack mode after IPv6 is enabled for it. Then, the ECS will have two IP addresses to access the intranet and Internet: an IPv4 address and an IPv6 address.
In some cases, an ECS cannot dynamically acquire an IPv6 address even if it meets all the requirements in Constraints. You need to configure the ECS to dynamically acquire IPv6 addresses. For public images:
- Before enabling dynamic IPv6 address assignment for a Linux public image, check whether IPv6 has been enabled and then whether dynamic IPv6 address assignment has been enabled. Currently, IPv6 is enabled for all Linux public images.
Constraints
- Ensure that IPv6 has been enabled on the subnet where the ECS works.
If IPv6 is not enabled on the subnet, enable it by referring to Enabling IPv6 for an ECS. IPv6 cannot be disabled once it is enabled.
- Ensure that the ECS flavor supports IPv6.
The ECS flavors that support IPv6 vary depending on regions and AZs. Check whether an ECS flavor supports IPv6 after you select a region and AZ on the management console.
If the value of IPv6 is Yes for an ECS flavor, the flavor supports IPv6.
AZ and Flavor determine whether IPv6 is supported.
After you select an AZ, if IPv6 is not displayed or the value of IPv6 is No, IPv6 is not supported by any or certain flavors in the AZ.
- Ensure that Self-assigned IPv6 address is selected during ECS creation.
- After the ECS is started, its hot-swappable NICs cannot automatically acquire IPv6 addresses.
- Only ECSs can work in dual-stack mode and BMSs cannot.
- Only one IPv6 address can be bound to a NIC.
Procedure
- Linux: Dynamic assignment of IPv6 addresses can be enabled automatically (recommended) or manually.
If a private image created from a CentOS 6.x or Debian ECS with automatic IPv6 address assignment enabled is used to create an ECS in an environment that does not support IPv6, the ECS may start slow because of IPv6 address assignment timeout. You can set the timeout duration for assigning IPv6 addresses by referring to Setting the Timeout Duration for IPv6 Address Assignment.
OS |
Automatically/Manually Enabling |
Reference |
---|---|---|
Linux |
Automatically (recommended) |
Linux (Automatically Enabling Dynamic Assignment of IPv6 Addresses) |
Linux |
Manually |
Linux (Manually Enabling Dynamic Assignment of IPv6 Addresses) |
Enabling IPv6 for an ECS
After IPv6 is enabled on the subnet where the ECS works, an IPv6 CIDR block is automatically assigned to the subnet. IPv6 cannot be disabled once it is enabled.
- Log in to the management console.
- Click in the upper left corner and select the desired region and project.
- Click . Under Compute, click Elastic Cloud Server.
- Click the target ECS to go to the detail page.
- In the ECS Information area, click the VPC name.
- Click the number in the Subnets column.
The Subnets page is displayed.
- In the subnet list, locate the target subnet and click its name.
- In the Subnet Information area, click Enable for IPv6 CIDR Block.
- Click Yes.
Linux (Automatically Enabling Dynamic Assignment of IPv6 Addresses)
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 dynamic IPv6 address assignment by following the instructions in Linux (Manually Enabling Dynamic Assignment of IPv6 Addresses).
- When you run ipv6-setup-xxx, the network service will be automatically restarted. As a result, the network is temporarily disconnected.
- If a private image created from a CentOS 6.x or Debian ECS with automatic IPv6 address assignment enabled is used to create an ECS in an environment that does not support IPv6, the ECS may start slow because of IPv6 address assignment timeout. Set the timeout duration for assigning IPv6 addresses to 30s by referring to Setting the Timeout Duration for IPv6 Address Assignment and try to create a new private image again.
- Run the following command to check whether IPv6 is enabled for the ECS:
ip addr
- If only an IPv4 address is displayed, IPv6 is disabled. Enable it by referring to Setting the Timeout Duration for IPv6 Address Assignment.
Figure 1 IPv6 disabled
- If a link-local address (starting with fe80) is displayed, IPv6 is enabled but dynamic assignment of IPv6 addresses is not enabled.
- If the following address is displayed, IPv6 is enabled and an IPv6 address has been assigned:
Figure 3 IPv6 enabled and an IPv6 address assigned
IPv6 is enabled for Linux public images by default, as shown in Figure 2.
- If only an IPv4 address is displayed, IPv6 is disabled. Enable it by referring to Setting the Timeout Duration for IPv6 Address Assignment.
- Enable IPv6 for the ECS.
- Run the following command to check whether IPv6 is enabled for the kernel:
- If a command output is displayed, IPv6 is enabled.
- If no information is displayed, IPv6 is disabled. 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 IPv6 is enabled for the kernel:
- Enable dynamic IPv6 address assignment for the ECS.
- Download ipv6-setup-rhel or ipv6-setup-debian with a required version and upload it to the target ECS.
ipv6-setup-xxx modifies the configuration file of a NIC to enable dynamic IPv6 address assignment or adds such a configuration file for a NIC, and then restarts the NIC or network service. Table 2 lists the download paths of ipv6-setup-rhel and ipv6-setup-debian.
Table 2 Download paths of ipv6-setup-rhel and ipv6-setup-debian 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/10
https://ecs-instance-driver.obs.cn-north-1.myhuaweicloud.com/ipv6/ipv6-setup-debian
- Run the following command to make ipv6-setup-xxx executable:
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 ipv6-setup-rhel or ipv6-setup-debian with a required version and upload it to the target ECS.
Linux (Manually Enabling Dynamic Assignment of IPv6 Addresses)
If a private image created from a CentOS 6.x or Debian ECS with automatic IPv6 address assignment enabled is used to create an ECS in an environment that does not support IPv6, the ECS may start slow because of IPv6 address assignment timeout. Set the timeout duration for assigning IPv6 addresses to 30s by referring to Setting the Timeout Duration for IPv6 Address Assignment and try to create a new private image again.
- Run the following command to check whether IPv6 is enabled for the ECS:
ip addr
- If only an IPv4 address is displayed, IPv6 is disabled. Enable it by referring to 2.
Figure 4 IPv6 disabled
- If a link-local address (starting with fe80) is displayed, IPv6 is enabled but dynamic assignment of IPv6 addresses is not enabled.
- If the following address is displayed, IPv6 is enabled and an IPv6 address has been assigned:
Figure 6 IPv6 enabled and an IPv6 address assigned
IPv6 is enabled for Linux public images by default, as shown in Figure 5.
- If only an IPv4 address is displayed, IPv6 is disabled. Enable it by referring to 2.
- Enable IPv6 for the ECS.
- Run the following command to check whether IPv6 is enabled for the kernel:
- If a command output is displayed, IPv6 is enabled.
- If no information is displayed, IPv6 is disabled. 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 IPv6 is enabled for the kernel:
- Enable dynamic IPv6 address assignment for the ECS.
- Ubuntu 18.04/20.04
- Run the following command to access /etc/netplan/:
cd /etc/netplan
- Run the following command to list the configuration file:
Figure 7 Configuration file name
- Run the following command to edit the configuration file:
- Append the following content to the configuration file (pay attention to the yaml syntax and text indentation):
ethernets: eth0: dhcp6: true
Figure 8 Edited configuration file
Save the changes and exit.
- Run the following command to make the changes take effect:
- Run the following command to access /etc/netplan/:
- Ubuntu 22.04
- Run the following command to access /etc/netplan/:
cd /etc/netplan
- Run the following command to list the configuration file:
Figure 9 Configuration file name
- Run the following command to edit the configuration file:
- Append the following content to the configuration file 01-netcfg.yaml (pay attention to the yaml syntax and text indentation):
ethernets: eth0: dhcp6: true
Figure 10 Edited configuration file
Save the changes and exit.
- Run the following command to make the changes take effect:
- Run the following command to edit /etc/NetworkManager/NetworkManager.conf:
vi /etc/NetworkManager/NetworkManager.conf
- Append the following content to the configuration file NetworkManager.conf (pay attention to the file format and indentation):
[main] plugins=ifupdown,keyfile dhcp=dhclient [ifupdown] managed=true [device] wifi.scan-rand-mac-address=no
Figure 11 Modification result
- Run the following command for the configuration to take effect:
- Run the following command to access /etc/netplan/:
- 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
- Add configurations for each NIC to 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 no IPv6 address is assigned 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:
- CentOS, EulerOS, or Fedora
- Open the configuration file /etc/sysconfig/network-scripts/ifcfg-eth0 of the primary NIC.
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 an ECS running CentOS 6, you need to edit the configuration files of its extension NICs. For example, if the extension 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. So, you also need to add a rule allowing the dhcpv6-client request to the ip6tables file.
- Run the following command to add the rule to ip6tables:
ip6tables -A INPUT -m state --state NEW -m udp -p udp --dport 546 -d fe80::/64 -j ACCEPT
- Run the following command to save the rule in ip6tables:
service ip6tables save
Figure 12 Example command
- Run the following command to add the rule to ip6tables:
- (Optional) For CentOS 7/CentOS 8, change the IPv6 link-local address mode of extension NICs to EUI64.
- Run the following command to query the NIC information:
Figure 13 Querying NIC information
- Run the following command to change the IPv6 link-local address mode of eth1 to EUI64:
nmcli con modify "Wired connection 1" ipv6.addr-gen-mode eui64
The NIC information varies depending on the CentOS series. In the command, Wired connection 1 needs to be replaced with the value in the NAME column of the queried NIC information.
- Run the following commands to bring eth1 down and up:
ifup eth1
- Run the following command to query the NIC information:
- Restart the network service.
- Perform 1 to check whether dynamic IPv6 address assignment is enabled.
- Open the configuration file /etc/sysconfig/network-scripts/ifcfg-eth0 of the primary NIC.
- SUSE, openSUSE, or CoreOS
SUSE 11 SP4 does not support dynamic IPv6 address assignment.
No additional configuration is required for SUSE 12 SP1 or SUSE 12 SP2.
No additional configuration is required for openSUSE 13.2 or openSUSE 42.2.
No additional configuration is required for CoreOS 10.10.5.
- Ubuntu 18.04/20.04
Setting the Timeout Duration for IPv6 Address Assignment
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 as follows:
- 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 14 Modification 1
Figure 15 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:
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.