If you want to implement IPv6 communication over the Internet or between private networks in a virtual private cloud (VPC), you can create an Elastic Compute Service (ECS) instance that is assigned IPv6 addresses in the VPC. Make sure that the VPC and the vSwitch that you want to connect to the instance are assigned IPv6 CIDR blocks. This topic describes how to configure an ECS instance to communicate over IPv6, assign an IPv6 address to an ECS instance, and configure an IPv6 address for an ECS instance.
Note
Due to the depletion of IPv4 addresses, network engineers spend a large amount of time and effort resolving issues such as address conflicts in an IPv4 environment. Compared with IPv4 addresses, more IPv6 addresses are available and allow more types of devices to access the Internet.
Limits
Regions that support IPv6 gateways
Area | Region |
China | China (Qingdao), China (Beijing), China (Zhangjiakou), China (Hohhot), China (Ulanqab), China (Hangzhou), China (Shanghai), China (Nanjing - Local Region), China (Fuzhou - Local Region), China (Shenzhen), China (Heyuan), China (Guangzhou), China (Chengdu), and China (Hong Kong) |
Asia Pacific | Philippines (Manila), Singapore, Japan (Tokyo), South Korea (Seoul), Indonesia (Jakarta), Malaysia (Kuala Lumpur), and Thailand (Bangkok) |
Europe and Americas | US (Virginia), US (Silicon Valley), and Germany (Frankfurt) |
Middle East | SAU (Riyadh - Partner Region) Important The SAU (Riyadh - Partner Region) region is operated by a partner. |
Instance families that do not support IPv6
ic5, compute-intensive instance family
se1, memory-optimized instance family
d1, big data instance family
i2g, instance family with local SSDs, and i1, instance family with local SSDs
hfc5, compute-optimized instance family with high clock speeds, and hfg5, general-purpose instance family with high clock speeds
ebmg5, general-purpose ECS Bare Metal Instance family, and ebmr5s, network-enhanced memory-optimized ECS Bare Metal Instance family
xn4, n4, mn4, and e4, previous-generation shared instance families
n1, n2, and e3, shared instance families
sn2, general-purpose instance family, and sn2, general-purpose instance family
Procedure
Note
You can click Quick Deploy to perform the following operations.
Step 1: Assign an IPv6 address
Assign an IPv6 address to an ECS instance to allow the instance to communicate with other instances or the Internet over IPv6.
Assign an IPv6 address to an existing instance
Assign an IPv6 address when you create an instance
Log on to the ECS console.
In the left-side navigation pane, choose .
In the top navigation bar, select the region and resource group to which the resource belongs.
Find the instance that you want to manage and choose in the Actions column.
In the Manage Secondary Private IP Address dialog box, assign an IPv6 address as prompted.
Important
If the IPv6 feature is disabled for the vSwitch to which the instance is connected, click Enable IPv6 for vSwitch to enable the IPv6 feature on the vSwitch page. For information about how to enable the IPv6 feature for a vSwitch, see Enable IPv6 for a vSwitch.
Click Confirm.
When you create an instance, take note of the following parameters. For information about other parameters, see Create an instance on the Custom Launch tab.
Network and Zone: Select a VPC and a vSwitch that are assigned IPv6 CIDR blocks. If IPv6 is disabled for a vSwitch, see Enable IPv6 for a vSwitch.
Instance: Search for instance types that support IPv6 and select an instance type from the search results.
Bandwidths & Security Groups: Click ENI|IPv6(Optional) and select Assign IPv6 Address Free of Charge.
After you assign the IPv6 address to the instance, you can view information about the IPv6 address in the ECS console. For more information, see View IP addresses.
Step 2: Configure an IPv6 address
You can configure an IPv6 address for a network interface card (NIC) of an ECS instance. This way, the IPv6 address can be identified and takes effect in the operating system of the instance.
Specific images support automatic configuration and recognition of IPv6 addresses. Perform the following steps to check whether the operating system of the ECS instance can recognize IPv6 addresses.
Linux instance
Windows instance
Connect to the Windows instance.
For more information, see Connect to a Windows instance by using a password.
Open Command Prompt in Windows and run the ipconfig
command.
The following command output indicates that the IPv6 address is automatically recognized as expected. Then, skip this step of configuring IPv6. Otherwise, proceed with the following operations.
Configure an IPv6 address.
Important
To automatically configure an IPv6 address, you must install Cloud Assistant Agent. If your instance does not support Cloud Assistant Agent or Cloud Assistant Agent is not installed on your instance, manually configure an IPv6 address.
(Recommended) Automatically configure an IPv6 address
Manually configure an IPv6 address for a Linux instance
Manually configure an IPv6 address for a Windows instance
Prerequisites
Cloud Assistant Agent is installed on the instance. If Cloud Assistant Agent is not installed on the instance, see Install Cloud Assistant Agent.
The instance runs one of the following operating systems: Alibaba Cloud Linux 2, Alibaba Cloud Linux 3, CentOS 6, CentOS 7, CentOS 8, Red Hat 6, Red Hat 7, Anolis OS, Fedora, Ubuntu 14, Ubuntu 16, Ubuntu 18, Ubuntu 20, Debian 8, Debian 9, Debian 10, Debian 11, SUSE 11, SUSE 12, SUSE 15, openSUSE 15, openSUSE 42, and FreeBSD 11.
Important
During the configuration, Cloud Assistant is used, and NICs and the network service are restarted. This may cause a brief network interruption. Proceed with caution.
Procedure
Connect to the Linux instance.
For more information, see Use Workbench to log on to a Linux instance over the Internet or a private network.
Run the following command to configure an IPv6 address.
Note
By default, the following command automatically checks whether the ecs-utils-ipv6
plug-in is installed or whether the most recent version of the plug-in is installed. If the plug-in is not installed or runs an earlier version, the system automatically downloads and installs the latest version of the plug-in. Make sure that the ECS instance can access the Internet.
sudo acs-plugin-manager --exec --plugin=ecs-utils-ipv6
Connect to the Linux instance.
For more information, see Use Workbench to log on to a Linux instance over the Internet or a private network.
Run the ip addr | grep inet6
or ifconfig | grep inet6
command to check whether IPv6 is enabled for the instance.
If the command output does not contain inet6
information, IPv6 is disabled for the instance. Perform the following operations to enable IPv6.
Alibaba Cloud Linux 2 and Alibaba Cloud Linux 3
CentOS 6 and CentOS 7
Debian 8 and Debian 9
Ubuntu 14, Ubuntu 16, and openSUSE 42
FreeBSD 11
SUSE 11 and SUSE 12
Run the following command to modify the /etc/sysctl.conf
configuration file:
Press the I
key to enter Insert mode, find the following content, and replace 1
at the end of each line with 0
:
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 close the file.
Run the following command to check whether the configurations in the /etc/sysctl.conf
file are consistent with the configurations in the /etc/sysctl.conf
file in the initram file system (initramfs):
diff -u /etc/sysctl.conf <(lsinitrd -f /etc/sysctl.conf)
Note
An initramfs is configured for Alibaba Cloud Linux 2. If the configurations in the /etc/sysctl.conf
file in the initramfs are inconsistent with the configurations in the /etc/sysctl.conf
file, the system may accept the configurations in the /etc/sysctl.conf file in the initramfs.
If the configurations are inconsistent, run the following command to generate a new initramfs
:
Restart the instance for the configurations to take effect. For more information, see Restart an instance.
Run the ip addr | grep inet6
or ifconfig | grep inet6
command to check whether IPv6 is enabled.
If the command output contains inet6
information, IPv6 is enabled.
Run the following command to modify the /etc/modprobe.d/disable_ipv6.conf
configuration file:
vi /etc/modprobe.d/disable_ipv6.conf
Press the I
key to enter Insert mode and replace options ipv6 disable=1
with options ipv6 disable=0
.
Press the Esc
key, enter :wq
, and then press the Enter key to save the changes and close the file.
Run the following command to modify the /etc/sysconfig/network
configuration file:
vi /etc/sysconfig/network
Press the I
key to enter Insert mode and replace NETWORKING_IPV6=no
with NETWORKING_IPV6=yes
.
Press the Esc
key, enter :wq
, and then press the Enter key to save the changes and close the file.
(Optional) Run the following commands in sequence to reload the IPv6 module.
Note
If the instance runs a CentOS 6 operating system, perform this step. Otherwise, skip this step.
modprobe ipv6 -r
modprobe ipv6
lsmod | grep ipv6
If the IPv6 module is loaded, the following content is returned:
Note
The parameter value on the third line of the returned content cannot be 0. Otherwise, you must re-enable IPv6.
Run the following command to modify the /etc/sysctl.conf
configuration file:
Press the I
key to enter Insert mode, find the following content, and then replace 1
at the end of each line with 0
:
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1
Press the Esc
key, enter :wq
, and then press the Enter key to save the changes and close the file.
Run the following command for the configurations to take effect:
Run the following command to modify the /etc/default/grub
configuration file:
Press the I
key to enter Insert mode and delete ipv6.disable=1
from the file.
Press the Esc
key, enter :wq
, and then press the Enter key to save the changes and close the file.
Run the following command to modify the /boot/grub/grub.cfg
configuration file:
Press the I
key to enter Insert mode and delete ipv6.disable=1
from the file.
Press the Esc
key, enter :wq
, and then press the Enter key to save the changes and close the file.
Restart the Linux instance. For more information, see Restart an instance.
Run the following command to modify the /etc/sysctl.conf
configuration file:
Press the I
key to enter Insert mode, find the following content, and then replace 1
at the end of each line with 0
.
net.ipv6.conf.all.disable_ipv6 = 0
net.ipv6.conf.default.disable_ipv6 = 0
net.ipv6.conf.lo.disable_ipv6 = 0
Press the Esc
key, enter :wq
, and then press the Enter key to save the changes and close the file.
Run the following command for the configurations to take effect:
Run the following command to modify the vi /etc/sysctl.conf
configuration file:
Press the I
key to enter Insert mode, find the following content, and then replace 1
at the end of each line with 0
.
net.ipv6.conf.all.disable_ipv6 = 0
net.ipv6.conf.default.disable_ipv6 = 0
net.ipv6.conf.lo.disable_ipv6 = 0
Press the Esc
key, enter :wq
, and then press the Enter key to save the changes and close the file.
Run the following command to allow the configurations to take effect:
Run the following command to modify the /etc/rc.conf
configuration file:
Press the I
key to enter Insert mode and add ipv6_activate_all_interfaces="YES"
to the file.
Press the Esc
key, enter :wq
, and then press the Enter key to save the changes and close the file.
Run the following command to restart the network service for the configurations to take effect:
Run the following command to modify the /etc/modprobe.d/50-ipv6.conf
configuration file:
vi /etc/modprobe.d/50-ipv6.conf
Press the I
key to enter Insert mode and delete install ipv6 /bin/true
from the file.
Press the Esc
key, enter :wq
, and then press the Enter key to save the changes and close the file.
Run the following command to modify the vi /etc/sysctl.conf
configuration file:
Press the I
key to enter Insert mode, find the following content, and then replace 1
at the end of each line with 0
.
net.ipv6.conf.all.disable_ipv6 = 0
net.ipv6.conf.default.disable_ipv6 = 0
net.ipv6.conf.lo.disable_ipv6 = 0
Press the Esc
key, enter :wq
, and then press the Enter key to save the changes and close the file.
Run the following command for the configurations to take effect:
If the command output contains inet6
information, IPv6 is enabled for the instance. You can configure an IPv6 address.
-
Configure an IPv6 address.
Alibaba Cloud Linux 2, Alibaba Cloud Linux 3, CentOS 6, CentOS 7, Red Hat 6, and Red Hat 7
CentOS 8
Debian 8, Debian 9, Debian 10, Debian 11, and Ubuntu 16
Ubuntu 18 and Ubuntu 20
Ubuntu 14
FreeBSD 11
Anolis OS 7.9, Anolis OS 8.4, CentOS Stream, and Fedora
Run the following command to modify the NIC configuration file:
vi /etc/sysconfig/network-scripts/ifcfg-eth0
Replace eth0
with the actual NIC name. Save the changes and exit.
Press the I
key to enter Insert mode. Add the following configurations based on the actual information in the file:
Press the Esc
key, enter :wq
, and then press the Enter key to save the changes and close the file.
Restart the instance for the configurations to take effect. For more information, see Restart an instance.
Check whether the NIC configuration file contains the IPV6INIT=yes
and DHCPV6C=yes
configurations. If yes, proceed to the next step. If not, add the configurations to the file.
vi /etc/sysconfig/network-scripts/ifcfg-eth0
In this example, eth0
is used. Replace eth0 with the actual NIC name. Save the changes and exit.
Disable the feature that allows cloud-init to modify the NIC files in the /etc/sysconfig/network-scripts/
directory.
Note
You do not need to manually configure the assigned IPv6 addresses. However, the IPv6 addresses may be lost when the instance is restarted. You must disable the feature that allows cloud-init to modify NIC files.
Run the vi /etc/cloud/cloud.cfg
command to open the NIC configuration file.
Add the following content before Example datasource config
:
network:
config: disabled
Save the changes and exit.
Restart the instance for the configurations to take effect. For more information, see Restart an instance.
Run the vi /etc/network/interfaces
command to open the NIC configuration file and add the following content to the file based on the actual information:
Replace eth0
with the actual NIC name. Save the changes and exit.
Restart the instance for the configurations to take effect. For more information, see Restart an instance.
Disable the feature that allows cloud-init to modify the NIC files in the /etc/sysconfig/network-scripts/
directory.
Note
You do not need to manually configure the assigned IPv6 addresses. However, the IPv6 addresses may be lost when the instance is restarted. You must disable the feature that allows cloud-init to modify NIC files.
Run the vi /etc/cloud/cloud.cfg
command to open the NIC configuration file.
Add the following information before Example datasource config
:
network:
config: disabled
Save the changes and exit.
Restart the instance for the configurations to take effect. For more information, see Restart an instance.
Run the vi /etc/network/interfaces
command to open the NIC configuration file and add the following content to the file based on the actual information:
Replace eth0
with the actual NIC name. Save the changes and exit.
Restart the instance for the configurations to take effect. For more information, see Restart an instance.
Run the vi /etc/rc.conf
command to open the NIC configuration file and add the following content to the file based on the actual information:
ipv6_enable="YES"
ipv6_ifconfig_vtnet0="<IPv6 address> <Subnet prefix length>"
Replace vtnet0
with the actual NIC name. Save the changes and exit.
Apply the following changes to the file. Then, save the changes and exit.
ip6addrctl_enable="YES"
ipv6_activate_all_interfaces="YES"
ipv6_network_interfaces="auto"
After you apply the changes, the configuration file contains the following content:
hostname="Aliyun"
sshd_enable="YES"
dumpdev="NO"
ipv6_enable="YES"
ip6addrctl_enable="YES"
ip6addrctl_policy="ipv4_prefer"
ipv6_activate_all_interfaces="YES"
ipv6_network_interfaces="auto"
ifconfig_lo0="inet 127.0.0.1 netmask 255.0.0.0"
ifconfig_vtnet0="inet 192.168.XX.XX netmask 255.255.255.0"
ipv6_ifconfig_vtnet0="2001:XXXX:4:4:4:4:4:4 prefixlen 64"
defaultrouter="192.168.XX.XX"
hostname="freebsd"
Restart the instance for the configurations to take effect. For more information, see Restart an instance.
Check whether the NIC configuration file contains the IPV6INIT=yes
and DHCPV6C=yes
configurations. If yes, no additional operations are required. If not, add the configurations to the file.
vi /etc/sysconfig/network-scripts/ifcfg-eth0
Replace eth0
with the actual NIC name. Save the changes and exit.
Restart the instance for the configurations to take effect. For more information, see Restart an instance.
Connect to the Windows instance.
For more information, see Connect to a Windows instance by using a password.
Open Command Prompt and run the ipconfig
command to check whether IPv6 is enabled for the instance.
If the command output does not contain inet6
information, IPv6 is disabled for the instance. Perform the following operations to enable IPv6.
Choose .
Click the name of the current network connection. In the dialog box that appears, click Properties.
Select Internet Protocol Version 6 (TCP/IPv6).
To enable IPv6 in Windows Server 2008, Windows Server 2012, Windows Server 2016, Windows Server 2019, or Windows Server 2022, perform the following operations:
Check whether the IPv6 option is selected. If the IPv6 option is not selected, select the option and click OK.
To enable IPv6 in Windows Server 2003, perform the following operations:
The operations vary based on whether IPv6 is installed.
If IPv6 is installed, select Internet Protocol Version 6 (TCP/IPv6) and click OK.
If IPv6 is not installed, perform the following operations:
In the Local Area Connection Properties dialog box, click Install. In the Select Network Component Type dialog box, choose .
In the Select Network Protocol dialog box, select and click OK.
Select Internet Protocol Version 6 (TCP/IPv6) and click OK.
If the command output contains inet6
information, IPv6 is enabled for the instance. You can configure an IPv6 address.
Configure an IPv6 address.
On the Instance Details page, obtain the generated IPv6 address.
-
Configure the IPv6 address.
To configure an IPv6 address in Windows Server 2008, Windows Server 2012, or Windows Server 2016, perform the following operations:
Choose > Network and Sharing Center.
Click the name of the current network connection. In the dialog box that appears, click Properties.
Choose .
Select Use the Following IPv6 Address, enter the IPv6 address, subnet prefix length, and IPv6 gateway, and then click OK.
(Optional) To associate multiple IPv6 addresses, perform the following operations: In the Internet Protocol Version 6 (TCP/IP) Properties dialog box, click Advanced. In the Advanced Settings dialog box, click Add to add multiple IPv6 addresses, and then click OK.
To configure an IPv6 address in Windows Server 2003, perform the following operations:
Choose to view the current network connection name. In this example, Local Area Connection 2 is displayed.
On the Windows desktop, press Win+R
to open the Run dialog box. Then, enter cmd
and click OK to open Command Prompt.
Add IPv6 addresses.
Run the following command to add a single IPv6 address:
netsh interface ipv6 add address "Local Area Connection 2" <IPv6 address>
Run the following commands to add multiple IPv6 addresses:
netsh interface ipv6 add address "Local Area Connection 2" <IPv6 address 1>
netsh interface ipv6 add address "Local Area Connection 2" <IPv6 address 2>
Run the following command to add the default route:
netsh interface ipv6 add route ::/0 "Local Area Connection 2" <IPv6 gateway>
(Conditionally required) If your ECS instance runs a Linux operating system, perform this step. Otherwise, skip this step.
Run the following command to check whether the multi-NIC configuration tool is installed on the instance:
If the following information is returned, the multi-NIC configuration tool is pre-installed on the instance. You need to modify the eni-function
file of the multi-NIC configuration tool.
Note
By default, the multi-NIC configuration tool does not support IPv6. If the tool is pre-installed on a Linux instance, the NICs in the Linux system cannot automatically identify IPv6 addresses, and the system cannot obtain IPv6 addresses after the instance is restarted.
Modify the eni-function
file
Run the following command to modify the eni-function
file:
vim /etc/eni_utils/eni-function
Press the I
key to enter Insert mode, change IPV6INIT=no
to IPV6INIT=yes
, add DHCPV6C=yes
, save the changes, and then exit.
Check whether the configuration is successful. Run the ifconfig
or ipconfig
command. If the command output contains the result obtained in Step 1, the configuration is successful.
(Optional) Step 3: Enable IPv6 Internet bandwidth
By default, the IPv6 address of an instance can be used only for communications between private networks. To connect to the Internet by using the IPv6 address, enable IPv6 Internet bandwidth.
Enable IPv6 Internet 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 details page of the IPv6 gateway, click the IPv6 Internet Bandwidth tab, find the IPv6 address for which you want to enable Internet bandwidth, and then click Activate Internet Bandwidth in the Actions column.
On the IPv6 Internet Bandwidth (PostPay) page, specify the parameters described in the following table, click Buy Now, and then complete the payment.
Parameter | Description |
Traffic | Select a metering 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: Test the connectivity of the IPv6 address
Test the connectivity of the IPv6 address to ensure that the instance to which the IPv6 address is assigned can communicate with the Internet.
Note
When you test the network connectivity of the IPv6 address, make sure that the server and client support IPv6 and are configured with IPv6 addresses.
Test Internet connectivity
Test private network connectivity
The following command output indicates that the instance can access the website.
Note
In this example, the aliyun.com website supports IPv6. After your ECS instance is configured, you can access the aliyun.com website over IPv6 on the instance.
Run the ping6 <Private IPv6 address of ECS02>
command on the ECS01 instance to ping
the IPv6 address of the ECS02 instance and check whether ECS01 can access ECS02 over the private network.
If ECS01 can receive ICMPv6 echo reply packets, the connection is established. The test result shows that ECS01 can access ECS02 by using the IPv6 address.
Run the ping6
command on the ECS02 instance to ping
the IPv6 address of the ECS01 instance and check whether ECS02 can access ECS01 over the private network.
If ECS02 can receive ICMPv6 echo reply packets, the connection is established. The test result shows that ECS02 can access ECS01 by using the IPv6 address.
Note
In this example, ECS01 and ECS02 must be assigned with IP addresses.
Related operations
Add IPv6 security group rules
IPv4 communication and IPv6 communication are independent of each other. If the current security group rules do not meet your business requirements, configure IPv6 security group rules for your instances to increase network security.
Add IPv6 security group rules
Log on to the ECS console.
In the left-side navigation pane, choose .
In the top navigation bar, select the region and resource group to which the resource belongs.
Find the security group to which you want to add rules and click Manage Rules in the Operation 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 information about how to add a security group rule, see Add a security group rule.
Note
When you add an IPv6 security group rule, set Authorization Object to an IPv6 CIDR block. Example: 2001:db8:1234:1a00::***
. For more information about security group rules, see Security group rules.
Delete an assigned IPv6 address
You can delete IPv6 addresses that you no longer need. After you delete the IPv6 address of an ECS instance, the instance can still use IPv4 addresses. This section describes how to delete an IPv6 address in the ECS console.
Important
Make sure that the instance is in the Running or Stopped state.
Procedure
Log on to the ECS console.
In the left-side navigation pane, choose .
In the top navigation bar, select the region and resource group to which the resource belongs.
On the Elastic Network Interfaces page, find the ENI that is bound to the instance and assigned an IPv6 address and click Manage ENI IP Addresses in the Operation column.
In the Manage ENI IP Addresses dialog box, click the icon to the right of an IPv6 address in the IPv6 section.
Click Confirm.
References
If an IPv6 address does not require access to the Internet, you can delete the Internet bandwidth of the IPv6 address. For more information, see the Delete IPv6 Internet bandwidth section of the "Enable and manage IPv6 Internet bandwidth" topic.
You can add and manage IPv6 routes in a routing table to manage IPv6 traffic in a VPC. For more information, see Create and manage IPv6 routes.