All Products
Search
Document Center

:Classic network how an ECS instance creates a custom image and generates a VPC network type instance from the image

Last Updated:Feb 22, 2021

Overview

When you use an Classic network ECS instance to generate an image and then use the image to generate a VPC network-type ECS instance, an exception is detected in the network-related configurations. Classic network residual information about the original instance. Therefore, you need to configure the image before generating it.

Details

This topic takes CentOS 7.6 as an example. For a classic network instance running CentOS 7.6, you must change the static configuration of related network services to dynamic configuration before creating a custom image. And set cloud-init service to start up automatically so that the configuration can be initialized when the VPC instance is created.

  1. Run the following commands in sequence to delete the static route configuration:
    cd /etc/sysconfig/network-scripts/
    rm -f route-eth*
  2. Run the following command to delete ifcfg-eth1 file.
    (: classic network instances under normal circumstances there are two network interface controller, eth0 and eth1, respectively, must not use the intranet and the Internet network interface controller, you must delete all eth1 public network interface controller, otherwise it will lead to the network service failed to start.
    rm -f ifcfg-eth1
  3. Edit the ifcfg-eth0 file and change the BOOTPROTO parameter to dhcp.
    note: by default, the classic network is configured with a static IP address. If you do not modify the IP address, it will cause the cloud-init to misjudge that the instance already has network configuration during initialization and will not dynamically obtain the address.
    BOOTPROTO=dhcp
    DEVICE=eth0
    ONBOOT=yes

  4. Run the following command to clear the network configuration file.
    note: classic network the HOSTNAME and GATEWAY are configured in the instance, if they are not cleared, the route of the newly generated VPC network type instance will be abnormal.
    echo > /etc/sysconfig/network
  5. When you create a VPC-connected ECS instance by classic network an image generated from the ECS instance, you must write the cloud-init customization script and add the following command. 
    systemctl enable cloud-config.service
    systemctl enable cloud-final.service 
    systemctl enable cloud-init-local.service
    systemctl enable cloud-init.service


Related Documents

Applicable to

  • Cloud server ECS