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 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, IPv6 addresses are more sufficient and allow more types of devices to access the Internet.
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. |
Configure IPv6 Internet access and private network access for an ECS instance
Note You can click Quick Deploy to perform the following operations.
Step 1: Configure IPv6 Internet access and private network access for an ECS instance
Assign an IPv6 address to an ECS instance. For more information, see the Assign an IPv6 address to an ECS instance section of this topic.
(Conditionally required) Configure the IPv6 address. If the operating system of the ECS instance supports automatic configuration and recognition of IPv6 addresses, skip this step. For more information, see the Configure an IPv6 address section of this topic.
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.
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 more information, 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.
(Optional) 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 2: 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.
Test Internet connectivity
ping -6 aliyun.com
The following command output indicates that the instance can access the website.
Test private network connectivity
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.
Manage IPv6 addresses
Assign an IPv6 address to an ECS instance
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
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.
Assign an IPv6 address when you create an instance
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 the Enable IPv6 for an existing vSwitch section of the "Enable IPv6 for a vSwitch" topic.
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.
Configure an IPv6 address
You can configure an IPv6 address for an NIC of an ECS instance. This way, the IPv6 address can be identified and takes effect in the operating system of the instance.
Check whether you need to configure IPv6 addresses for your ECS instance. If the operating system of the ECS instance supports automatic configuration and recognition of IPv6 addresses, you do not need to configure IPv6 addresses. Skip this section.
Images whose operating systems support automatic configuration and recognition of IPv6 addresses
Note The operating system versions of the images that support automatic configuration and recognition of IPv6 addresses vary based on the actual environment. The following list provides some examples of the images.
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
Prerequisites
Cloud Assistant Agent is installed on the instance. If Cloud Assistant Agent is not installed on the instance, install Cloud Assistant Agent as described in 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 Connect to a Linux instance by using a password or key.
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
Manually configure an IPv6 address for a Linux instance
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
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.
Enable IPv6
Alibaba Cloud Linux 2 and Alibaba Cloud Linux 3
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 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
:
sudo dracut -v -f
Restart the instance to allow 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.
CentOS 6 and CentOS 7
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:
ipv6 xxxxx 8
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:
vi /etc/sysctl.conf
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:
sudo sysctl -p
Debian 8 and Debian 9
Run the following command to modify the /etc/default/grub
configuration file:
vi /etc/default/grub
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:
vi /boot/grub/grub.cfg
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:
vi /etc/sysctl.conf
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:
sudo sysctl -p
Ubuntu 14, Ubuntu 16, and openSUSE 42
Run the following command to modify the vi /etc/sysctl.conf
configuration file:
vi /etc/sysctl.conf
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:
sysctl -p
FreeBSD 11
Run the following command to modify the /etc/rc.conf
configuration file:
vi /etc/rc.conf
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:
/etc/netstart restart
SUSE 11 and SUSE 12
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:
vi /etc/sysctl.conf
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:
sysctl -p
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
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:
DHCPV6C=yes
IPV6INIT=yes
Press the Esc
key, enter :wq
, and then press the Enter key to save the changes and close the file.
Restart the instance to allow the configurations to take effect. For more information, see Restart an instance.
CentOS 8
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.
vi /etc/cloud/cloud.cfg
Add the following content before Example datasource config
:
network:
config: disabled
Save the changes and exit.
Restart the instance to allow the configurations to take effect. For more information, see Restart an instance.
Debian 8, Debian 9, Debian 10, Debian 11, and Ubuntu 16
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:
iface eth0 inet6 dhcp
Replace eth0
with the actual NIC name. Save the changes and exit.
Restart the instance to allow the configurations to take effect. For more information, see Restart an instance.
Ubuntu 18 and Ubuntu 20
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.
vi /etc/cloud/cloud.cfg
Add the following information before Example datasource config
:
network:
config: disabled
Save the changes and exit.
Restart the instance to allow the configurations to take effect. For more information, see Restart an instance.
Ubuntu 14
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:
iface eth0 inet6 dhcp
Replace eth0
with the actual NIC name. Save the changes and exit.
Restart the instance to allow the configurations to take effect. For more information, see Restart an instance.
FreeBSD 11
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 to allow the configurations to take effect. For more information, see Restart an instance.
Anolis OS 7.9, Anolis OS 8.4, CentOS Stream, and Fedora
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 to allow the configurations to take effect. For more information, see Restart an instance.
Manually configure an IPv6 address for a Windows 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.
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.
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:
ls /sbin/eni-ifscan
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.
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
You can delete the public IPv6 bandwidth if you no longer need the IPv6 address to communicate with the Internet. 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.