By default, when you create an Elastic Compute Service (ECS) instance, an IPv4 address instead of an IPv6 address is assigned to the instance. If you want to connect to the Internet from the instance by using an IPv6 address, configure an IPv6 address for the instance. This topic describes how to configure an IPv6 address for an ECS instance.
Prerequisites
Before you assign an IPv6 address to an instance when you create the instance in a virtual private cloud (VPC), the VPC and the vSwitch to connect to the instance are assigned IPv6 CIDR blocks. For more information, see Enable IPv6 for a VPC and Enable IPv6 for a vSwitch.
Before you assign an IPv6 address to an existing instance, the following requirements are met:
The instance supports IPv6. For information about whether an instance type supports IPv6, see Overview of instance families.
The network type of the instance is VPC. The VPC and vSwitch of the instance are assigned IPv6 CIDR blocks. For more information, see Enable IPv6 for a VPC and Enable IPv6 for a vSwitch.
The instance is in the Running or Stopped state.
Procedure
The following flowchart shows how to use IPv6 addresses.
Step 1: Create an IPv6 VPC
Before you configure an IPv6 address for an instance, create an IPv6 VPC for the instance.
By default, VPCs use IPv4. You can enable IPv6 based on your business requirements. For information about IPv6 addresses, see Overview.
If you have not created VPCs, create a VPC and enable IPv6 for it. For more information, see the "Create a VPC that supports both IPv4 and IPv6" section of the Enable IPv6 for a VPC topic.
If you have created VPCs, enable IPv6 for an existing VPC. For more information, see the "Enable IPv6 for an existing VPC" section of the Enable IPv6 for a VPC topic.
Step 2: Assign an IPv6 address
Before you configure an IPv6 address for an instance, assign the IPv6 address to the instance. The IPv6 address allows the instance to access other instances or external networks over IPv6.
Scenario 1: Assign an IPv6 address to an existing instance
You can configure event notifications in EventBridge or CloudMonitor to receive notifications for IP address events. After you assign an IPv6 address to an instance, you can receive a notification for the assignment. You can obtain information about the IPv6 address assignment, such as the IPv6 address and the associated elastic network interface (ENI) ID, and configure operations to be automatically performed in response to the notification. For more information, see Configure event notifications, ECS events, and the "Notifications for private IPv6 address assignment events" section of the IP address event notifications topic.
Log on to the ECS console.
In the left-side navigation pane, choose .
In the upper-left corner of the top navigation bar, select a region.
Find the instance that you want to manage and choose
in the Actions column.In the Manage Secondary Private IP Address dialog box, click Assign New IP next to IPv6 Address.
Use one of the following methods to assign an IPv6 address:
Auto-assignment: Do not specify an IP address in the field. This way, the system randomly assigns an IPv6 address to the instance.
Manual assignment: Specify an IPv6 address for the instance.
Click OK.
Scenario 2: Assign an IPv6 address to a new instance
For information about how to create an instance, see Create an instance by using the wizard. When you create an instance, take note of the following items:
In the Basic Configurations step, find IPv6-supported instance types and select an instance type.
In the Networking step, make the following configurations:
Select a VPC and vSwitch for which IPv6 is enabled.
Select Assign IPv6 Address Free of Charge.
In the Preview step, confirm that an automatically selected IPv6 address or your specified IPv6 address is assigned.
(Optional) Step 3: Enable IPv6 public bandwidth
By default, the IPv6 address of an instance can be used only for communications on the internal network. To provide connectivity over IPv6 to and from the Internet, enable IPv6 public bandwidth.
Log on to the VPC console.
In the left-side navigation pane, choose .
- In the top navigation bar, select the region where the IPv6 gateway is deployed.
On the IPv6 Gateway page, find the IPv6 gateway that corresponds to the VPC in which the instance resides and click the IPv6 gateway ID.
On the IPv6 Gateway Details page, click the IPv6 Internet Bandwidth tab, find the IPv6 address for which you want to enable Internet bandwidth, and then click Create IPv6 Internet Bandwidth in the Actions column.
On the IPv6 Internet Bandwidth (PostPay) page, set the parameters described in the following table, click Buy Now, and then complete the payment.
Parameter
Description
Traffic
Select a billing method for the Internet bandwidth.
Valid values: Pay-By-Bandwidth and Pay-By-Data-Transfer. For more information, see Billing rules.
Bandwidth
Specify a maximum value for the Internet bandwidth.
Billing cycle
Select a billing cycle for the Internet bandwidth. Valid values: Day (By Day) and Hour (By Hour).
If you set Traffic to Pay-By-Bandwidth, you can select only Day (By Day). If you set Traffic to Pay-By-Data-Transfer, you can select only Hour (By Hour).
Step 4: Configure an IPv6 address
You can assign an IPv6 address to a network interface controller (NIC) of an instance manually or automatically by using tools. This allows the IPv6 address to be identified and take effect in the operating system of the instance.
This section describes how to configure an IPv6 address for Linux and Windows instances.
Linux instance
Automate IPv6 address configuration (recommended)
The ecs-util-ipv6 tool can be used to batch configure IPv6 addresses that are assigned to instances or batch clear IPv6 configurations for instances that are not assigned IPv6 addresses.
The ecs-util-ipv6 tool has the following limits:
The ecs-util-ipv6 tool applies only to ECS instances that are located in VPCs and depends on instance metadata. Before you use this tool, make sure that you enable the network service and that allow outbound access to 100.100.100.200 on port 80. For more information, see Overview of ECS instance metadata.
When the ecs-util-ipv6 tool runs, NICs and the network service are restarted. This may cause a brief network interruption. Proceed with caution.
In this example, IPv6 address configuration is automated for a CentOS instance.
Connect to the Linux instance.
For more information, see Connect to a Linux instance by using a password or key.
Run the following command to download the ecs-util-ipv6 tool:
wget https://ecs-image-utils.oss-cn-hangzhou.aliyuncs.com/ipv6/rhel/ecs-utils-ipv6
The following table lists the download URLs of the ecs-util-ipv6 tool for different operating systems.
Series
Distribution
Download link
RHEL
CentOS 5/6/7/8
Red Hat 5/6/7
Anolis OS
Fedora
Alibaba Cloud Linux 2/3
Debian
Ubuntu 14/16/18/20
Debian 8/9/10/11
SLES
SUSE 11/12/15
OpenSUSE 15/42
FreeBSD
FreeBSD 11
Run the following command as an administrator to run the ecs-util-ipv6 tool.
NoteIf your instance is assigned an IPv6 address, the IPv6 address is automatically configured. Otherwise, the existing IPv6 address configurations are automatically cleared.
chmod +x ./ecs-utils-ipv6 ./ecs-utils-ipv6
Optional. If the instance image is an Ubuntu 14 public image, restart the instance to allow the configurations to take effect. For more information, see Restart instances.
You can run the following commands to enable IPv6, disable IPv6, configure IPv6 addresses for NICs, and automate IPv6 address configuration for NICs. By default, IPv6 address configuration is automated.
./ecs-utils-ipv6 #By default, no parameter configurations are required. Multiple IPv6 addresses are automatically configured for multiple NICs.
./ecs-utils-ipv6 --enable #Enable IPv6.
./ecs-utils-ipv6 --disable #Disable IPv6.
./ecs-utils-ipv6 --static <NIC name> #Have an IPv6 address automatically configured for an NIC.
./ecs-utils-ipv6 --static <NIC name> <IPv6 address> <Subnet prefix length> <IPv6 gateway> #Configure one or more IPv6 addresses for one or more NICs. Separate the addresses with spaces and enclose each address in double quotation marks (" ").
Replace <NIC name>
, <IPv6 address>
, <Subnet prefix length>
, and <IPv6 gateway>
with the actual values.
If you want to configure IPv6 addresses for multiple instances at a time, we recommend that you use Cloud Assistant or user data to configure a script that automates the configuration process. For more information, see Overview and Overview of ECS instance user data. Sample bash script that applies to RHEL operating systems:
#!/bin/sh
install_dir=/usr/sbin
install_path="$install_dir"/ecs-utils-ipv6
if [ ! -f "$install_path" ]; then
tool_url="http://ecs-image-utils.oss-cn-hangzhou.aliyuncs.com/ipv6/rhel/ecs-utils-ipv6"
# download the tool
if ! wget "$tool_url" -O "$install_path"; then
echo "[Error] download tool failed, code $?"
exit "$?"
fi
fi
# chmod the tool
if ! chmod +x "$install_path"; then
echo "[Error] chmod tool failed, code $?"
exit "$?"
fi
# run the tool
"$install_path"
Configure an IPv6 address for an instance that runs an Alibaba Cloud Linux 2 or 3 operating system
Connect to the Linux instance.
For more information, see Connect to a Linux instance by using a password or key.
Run the
ip addr | grep inet6
orifconfig | grep inet6
command to check whether IPv6 is enabled for the instance.NoteIPv6 is disabled in Alibaba Cloud Linux 2 images of the
aliyun_2_1903_64_20G_alibase_20190829.vhd
version and earlier. By default, IPv6 is enabled in Alibaba Cloud Linux 2 images of thealiyun_2_1903_x64_20G_alibase_20200221.vhd
version and later.If the command output contains
inet6
information, IPv6 is enabled for your instance. In this case, you can skip the "Enable IPv6" step and proceed to configure an IPv6 addressIf the command output does not contain
inet6
information, IPv6 is not enabled for your instance. Perform the following operations to enable IPv6.
Enable IPv6.
Run the following command to modify the
/etc/sysctl.conf
configuration file:vi /etc/sysctl.conf
Press the
I
key to enter Insert mode, find the following content, and then replace1
at the end of each line with0
.net.ipv6.conf.all.disable_ipv6 = 1 net.ipv6.conf.default.disable_ipv6 = 1 net.ipv6.conf.lo.disable_ipv6 = 1
To enable IPv6 for a specific NIC, use the following settings:
net.ipv6.conf.eth0.disable_ipv6 = 0
Press the
Esc
key, enter:wq
, and then press the Enter key to save the changes and exit Insert mode.Run the following command to check whether configurations in the
/etc/sysctl.conf
file are consistent with those in the/etc/sysctl.conf
file in the initramfs:diff -u /etc/sysctl.conf <(lsinitrd -f /etc/sysctl.conf)
NoteAn initramfs is configured for Alibaba Cloud Linux 2. If the configurations in the
/etc/sysctl.conf
file in the initramfs are inconsistent with those in the/etc/sysctl.conf
file, the system may accept the file in the initramfs.If the configurations are inconsistent, run the following command to generate a new initramfs:
sudo dracut -v -f
Run the following command to restart the instance to allow the configurations to take effect:
reboot
Run the
ifconfig
command to check whether IPv6 is enabled.If the command output contains the following information, IPv6 is enabled.
inet6 <Unicast address that starts with fe80::> inet6 <IPv6 address of the instance>
Configure an IPv6 address.
Run the following command to modify the NIC configuration file:
NoteReplace eth0 in the command with the actual identifier of your NIC.
vi /etc/sysconfig/network-scripts/ifcfg-eth0
Press the
I
key to enter Insert mode. Add the following configurations based on the actual information to the file:DHCPV6C=yes IPV6INIT=yes
Press the
Esc
key, enter:wq
, and then press the Enter key to save the changes and exit Insert mode.Run the following command to restart the instance to allow the configurations to take effect:
reboot
Configure an IPv6 address for an instance that runs an operating system of another series
Perform the following operations to configure an IPv6 address for an instance that runs an operating system of another series, such as CentOS, Debian, Ubuntu, or Fedora.
Connect to the Linux instance.
For more information, see Connect to a Linux instance by using a password or key.
Run the
ip addr | grep inet6
orifconfig | grep inet6
command to check whether IPv6 is enabled for the instance.NoteBy default, IPv6 is enabled on CentOS 8, Debian 10 and later, and Ubuntu 18 and later.
If the command output contains
inet6
information, IPv6 is enabled for your instance. In this case, you can skip the "Enable IPv6" step and proceed to configure an IPv6 address.If the command output does not contain
inet6
information, IPv6 is not enabled for your instance. Perform the following operations to enable IPv6.
Windows instance
Automate IPv6 address configuration (recommended)
The ecs-util-ipv6 tool can be used to configure IPv6 addresses for instances that are assigned IPv6 addresses, or clear IPv6 configurations for instances that are not assigned IPv6 addresses.
The ecs-util-ipv6 tool has the following limits:
The ecs-util-ipv6 tool applies only to ECS instances that are located in VPCs and depends on instance metadata. Before you use this tool, make sure that you enable the network service and that allow outbound access to 100.100.100.200 on port 80. For more information, see Overview of ECS instance metadata.
When the ecs-util-ipv6 tool runs, NICs and the network service are restarted. This may cause a brief network interruption. Proceed with caution.
Connect to the Windows instance.
For more information, see Connect to a Windows instance by using a password.
Download the version of the ecs-util-ipv6 tool based on the operating system of the instance:
Run
ecs-utils-ipv6.exe
as an administrator.ImportantIf your instance is assigned an IPv6 address, the IPv6 address is automatically configured. Otherwise, the existing IPv6 address configurations are automatically cleared.
If you want to configure IPv6 addresses for multiple instances at a time, we recommend that you use Cloud Assistant or user data to configure a script that automates the configuration process. For more information, see Overview and Overview of ECS instance user data. Sample PowerShell script that applies to 64-bit Windows Server 2003, 2008, 2012, 2016, 2019, and 2022:
#powershell
$install_dir="C:\Windows\system32"
$install_path = "$install_dir\ecs-utils-ipv6.exe"
if(-not (Test-Path -Path $install_path)){
# download the tool
$tool_url = 'http://ecs-image-utils.oss-cn-hangzhou.aliyuncs.com/ipv6/win/64/ecs-utils-ipv6.exe'
Invoke-WebRequest -uri $tool_url -OutFile $install_path
Unblock-File $install_path
}
# run the tool
Start-Process -FilePath "$install_path" -ArgumentList "--noenterkey" -NoNewWindow
Configure an IPv6 address
Perform the following operations to configure an IPv6 address:
Connect to the Windows instance.
For more information, see Connect to a Windows instance by using a password.
Check whether IPv6 is enabled for your instance.
On the Windows desktop, press
Win+R
to open the Run dialog box. Then, entercmd
and click OK to open Command Prompt.Run the
ipconfig
command.If IPv6 address information is returned, IPv6 is enabled for your instance. Otherwise, IPv6 is not enabled for the instance. You must enable IPv6 for the instance.
On the instance details page, obtain the IPv6 address that is assigned in Step 2: Assign an IPv6 address.
Step 5: Add IPv6 security group rules
Services that are assigned IPv4 addresses and services that are assigned IPv6 addresses cannot communicate with each other. If the current security group rules do not support your IPv6 services, you must configure IPv6 security group rules for your ECS instances.
Log on to the ECS console.
In the left-side navigation pane, choose .
In the upper-left corner of the top navigation bar, select a region.
Find the security group to which you want to add rules and click Add Rules in the Actions column.
On the details page of the security group, click the Inbound or Outbound tab in the Access Rule section.
Add security group rules. For more information, see Add a security group rule.
NoteYou must set Authorization Object to an IPv6 CIDR block. Example:
2001:db8:1234:1a00::***
. For more information about security group rules, see Security group rules.
Step 6: Test the connectivity of the IPv6 address
After you enable IPv6 public bandwidth, make sure that the IPv6 address of the instance can provide connectivity to and from the Internet.
In the following examples, the ping -6
command is run to check whether the instance can access aliyun.com
by using the IPv6 address.
Linux instance
Connect to the Linux instance for which an IPv6 address is configured.
For more information, see Connect to a Linux instance by using a password or key.
Run the following command to test the network connectivity:
ping -6 aliyun.com
A command output similar to the following one indicates that the instance can access the website.
Windows instance
Connect to the Windows instance for which an IPv6 address is configured.
For more information, see Connect to a Windows instance by using a password.
On the Windows desktop, press
Win+R
to open the Run dialog box. Then, entercmd
and click OK to open Command Prompt.Run the following command to test the network connectivity:
ping -6 aliyun.com
A command output similar to the following one indicates that the instance can access the website.