Help Center> Elastic Cloud Server> User Guide (Kuala Lumpur Region)> NICs> Dynamically Assigning IPv6 Addresses
Updated on 2022-08-16 GMT+08:00

Dynamically Assigning IPv6 Addresses

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:

  • By default, dynamic IPv6 address assignment is enabled for Windows public images. You do not need to configure it. The operations in Windows Server 2012 and Windows Server 2008 are for your reference only.
  • 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 but dynamic IPv6 address assignment is only enabled for Ubuntu 16 public images by default.

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" in Virtual Private Cloud User Guide.

  • Ensure that Self-assigned IPv6 address is selected during ECS creation.
  • After an 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

  • Windows: Windows Server 2012 and Windows Server 2008 are used as examples to describe how to enable dynamic assignment of IPv6 addresses in Windows.
  • Linux: Dynamic assignment of IPv6 addresses can be enabled automatically (recommended) or manually.

    For CentOS 6.x and Debian, after dynamic IPv6 address assignment is enabled for an ECS and the ECS is used to create an image, the new ECSs created from this image will start up slowly due to IPv6 address assignment timeout. You can rectify this issue by referring to Setting the Timeout Duration for IPv6 Address Assignment.

Table 1 Enabling dynamic assignment of IPv6 addresses for different OSs

OS

Automatically/Manually Enabling

Reference

Windows Server 2012

Automatically

Windows Server 2012

Windows Server 2008

Automatically

Windows Server 2008

Linux

Automatically (recommended)

Linux (Automatically Enabling Dynamic Assignment of IPv6 Addresses)

Linux

Manually

Linux (Manually Enabling Dynamic Assignment of IPv6 Addresses)

Windows Server 2012

  1. Check whether IPv6 is enabled for the ECS.

    Run the following command in the CMD window to check it:

    ipconfig

    • If an IPv6 address and a link-local IPv6 address are displayed, IPv6 is enabled and dynamic IPv6 assignment is also enabled.
      Figure 1 Querying the IPv6 address
    • If only a link-local IPv6 address is displayed, IPv6 is enabled but dynamic IPv6 assignment is not enabled. Go to 2.
      Figure 2 Link-local IPv6 address
    • If neither an IPv6 address nor link-local IPv6 address is displayed, IPv6 is disabled. Go to 3.
      Figure 3 IPv6 disabled

      By default, dynamic IPv6 address assignment is enabled for Windows public images, as shown in Figure 1. No additional configuration is required.

  2. Enable dynamic IPv6 address assignment.

    1. Choose Start > Control Panel.
    2. Click Network and Sharing Center.
    3. Click the Ethernet connection.
      Figure 4 Ethernet connection
    4. In the Ethernet Status dialog box, click Properties in the lower left corner.
    5. Select Internet Protocol Version 6 (TCP/IPv6) and click OK.
      Figure 5 Configuring dynamic IPv6 address assignment
    6. Perform 1 to check whether dynamic IPv6 address assignment is enabled.

  3. Enable and configure IPv6.

    1. In the Internet Protocol Version 6 (TCP/IPv6) Properties dialog box, configure an IPv6 address and a DNS server address.
      • IPv6 address: IPv6 address allocated during ECS creation. Obtain the value from the ECS list on the console.
      • Subnet prefix length: 64
      • Preferred DNS server: 240c::6666 (recommended)
      Figure 6 Configuring an IPv6 address and a DNS server address
    2. (Optional) Run the following command depending on your ECS OS.

      For Windows Server 2012, run the following command in PowerShell or CMD:

      Set-NetIPv6Protocol -RandomizeIdentifiers disabled

    3. Perform 1 to check whether dynamic IPv6 address assignment is enabled.

Windows Server 2008

  1. Check whether IPv6 is enabled for the ECS.

    Run the following command in the CMD window to check it:

    ipconfig

    • If an IPv6 address and a link-local IPv6 address are displayed, IPv6 is enabled and dynamic IPv6 assignment is also enabled.
      Figure 7 Querying the IPv6 address
    • If only a link-local IPv6 address is displayed, IPv6 is enabled but dynamic IPv6 assignment is not enabled. Go to 2.
      Figure 8 Link-local IPv6 address
    • If neither an IPv6 address nor link-local IPv6 address is displayed, IPv6 is disabled. Go to 3.
      Figure 9 IPv6 disabled

      By default, dynamic IPv6 address assignment is enabled for Windows public images, as shown in Figure 7. No additional configuration is required.

  2. Enable dynamic IPv6 address assignment.

    1. Choose Start > Control Panel.
    2. Click Network and Sharing Center.
    3. Click Change adapter settings.
    4. Right-click the local network connection and choose Properties.
    5. Select Internet Protocol Version 6 (TCP/IPv6) and click OK.
      Figure 10 Configuring dynamic IPv6 address assignment
    6. Perform 1 to check whether dynamic IPv6 address assignment is enabled.

  3. Enable and configure IPv6.

    1. Choose Start > Control Panel > Network Connection > Local Connection.
    2. Select Properties, select the following options, and click Install.
      Figure 11 Enabling and configuring IPv6
    3. Select Protocol and click Add.
      Figure 12 Adding the protocol
    4. Select Microsoft TCP/IP Version 6 and click OK.
      Figure 13 Network protocols
    5. (Optional) Run the following commands depending on your ECS OS.

      For 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.

    6. Perform 1 to check whether dynamic IPv6 address assignment is enabled.

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.
  1. 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 14 IPv6 disabled
    • If a link-local address (starting with fe80) is displayed, IPv6 is enabled but dynamic assignment of IPv6 addresses is not enabled.
      Figure 15 IPv6 enabled
    • If the following address is displayed, IPv6 is enabled and an IPv6 address has been assigned:
      Figure 16 IPv6 enabled and an IPv6 address assigned

    IPv6 is enabled for Linux public images by default, as shown in Figure 15. IPv6 and dynamic IPv6 address assignment are enabled for Ubuntu 16 public images by default, as shown in Figure 16.

  2. Enable IPv6 for the ECS.

    1. Run the following command to check whether IPv6 is enabled for the kernel:

      sysctl -a | grep ipv6

      • 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.
    2. Run the following command to load the IPv6 module:

      modprobe ipv6

    3. Add the following content to the /etc/sysctl.conf file:

      net.ipv6.conf.all.disable_ipv6=0

    4. Save the configuration and exit. Then, run the following command to load the configuration:

      sysctl -p

  3. Enable dynamic IPv6 address assignment for the ECS.

    1. 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.

      Contact the administrator to obtain the download paths of ipv6-setup-rhel and ipv6-setup-debian.

    2. Run the following command to make ipv6-setup-xxx executable:

      chmod +x ipv6-setup-xxx

    3. Run the following command to enable dynamic IPv6 address assignment for a NIC:

      ./ipv6-setup-xxx --dev [dev]

      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.

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.

  1. 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 17 IPv6 disabled
    • If a link-local address (starting with fe80) is displayed, IPv6 is enabled but dynamic assignment of IPv6 addresses is not enabled.
      Figure 18 IPv6 enabled
    • If the following address is displayed, IPv6 is enabled and an IPv6 address has been assigned:
      Figure 19 IPv6 enabled and an IPv6 address assigned

    IPv6 is enabled for Linux public images by default, as shown in Figure 18. IPv6 and dynamic IPv6 address assignment are enabled for Ubuntu 16 public images by default, as shown in Figure 19.

  2. Enable IPv6 for the ECS.

    1. Run the following command to check whether IPv6 is enabled for the kernel:

      sysctl -a | grep ipv6

      • 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.
    2. Run the following command to load the IPv6 module:

      modprobe ipv6

    3. Add the following content to the /etc/sysctl.conf file:

      net.ipv6.conf.all.disable_ipv6=0

    4. Save the configuration and exit. Then, run the following command to load the configuration:

      sysctl -p

  3. Enable dynamic IPv6 address assignment for the ECS.

    • Ubuntu

      For Ubuntu 18.04 and 20.04, perform the following steps. For Ubuntu 16.04, skip these steps because dynamic IPv6 address assignment is enabled by default.

      1. Run the following command to access /etc/netpaln/:

        cd /etc/netplan

      2. Run the following command to list the configuration file:

        ls

        Figure 20 Configuration file name
      3. Run the following command to edit the configuration file:

        vi 01-network-manager-all.yaml

      4. Append the following content to the configuration file (pay attention to the yaml syntax and text indentation):
        ethernets:
         eth0:
          dhcp6: true
        Figure 21 Edited configuration file

        Save the changes and exit.

      5. Run the following command to make the changes take effect:

        sudo netplan apply

    • Debian
      1. 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
      2. 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
      3. Run the following command to restart the network service:

        service networking restart

        If no IPv6 address is assigned after the NICs are brought down and up, you can run this command to restart the network.

      4. Perform 1 to check whether dynamic IPv6 address assignment is enabled.
    • CentOS, EulerOS, or Fedora
      1. 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
      2. Edit the /etc/sysconfig/network file to add or modify the following line:
        NETWORKING_IPV6=yes
      3. 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.

        1. 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

        2. Run the following command to save the rule in ip6tables:

          service ip6tables save

          Figure 22 Example command
      4. (Optional) For CentOS 7/CentOS 8, change the IPv6 link-local address mode of extension NICs to EUI64.
        1. Run the following command to query the NIC information:

          nmcli con

          Figure 23 Querying NIC information
        2. 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.

        3. Run the following commands to bring eth1 down and up:

          ifdown eth1

          ifup eth1

      5. Restart the network service.
        1. For CentOS 6, run the following command to restart the network service:

          service network restart

        2. For CentOS 7/EulerOS/Fedora, run the following command to restart the network service:

          systemctl restart NetworkManager

      6. Perform 1 to check whether dynamic IPv6 address assignment is enabled.
    • 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.

Setting the Timeout Duration for IPv6 Address Assignment

Set the timeout duration depending on the OS type.

  • CentOS 6.x:
    1. Run the following command to edit the dhclient.conf file:

      vi /etc/dhcp/dhclient.conf

    2. Press i to enter editing mode and add the timeout attribute to the file.
      timeout  30;
    3. Enter :wq to save the settings and exit.
  • Debian 7.5:
    1. Run the following command to edit the networking file:

      vi /etc/init.d/networking

    1. Press i to enter editing mode and add the timeout attribute.
      Figure 24 Modification 1
      Figure 25 Modification 2
  • Debian 8.2.0/8.8.0
    1. Run the following command to edit the network-pre.conf file:

      vi /lib/systemd/system/networking.service.d/network-pre.conf

    2. Press i to enter editing mode and add the timeout attribute to the file.
      [Service]
      TimeoutStartSec=30
  • Debian 9.0
    1. Run the following command to edit the networking.service file:

      vi /etc/system/system/network-online.target.wants/networking.service

    2. Press i to enter editing mode and change TimeoutStartSec=5min to TimeoutStartSec=30.