All Products
Search
Document Center

:Network issues after creating an instance in a VPC from a custom image

Last Updated:Oct 16, 2025

Problem description

After you create an Elastic Compute Service (ECS) instance in a virtual private cloud (VPC) from a custom image, you may experience network connectivity issues.

Causes

This issue can occur for several reasons. This topic uses a CentOS 7 system as an example.

  • The GATEWAY parameter is configured in the /etc/sysconfig/network file of the custom image. When an ECS instance is created from this custom image, the instance retains this parameter. Although the instance gets an IP address through DHCP, the default route is incorrect. This causes the network to become unavailable.

  • The /etc/udev/rules.d/70-persistent-net.rules file of the custom image contains network rules. For example, if the file contains the following rule, an ECS instance created from the custom image cannot get an IP address for its eth0 network interface card (NIC) after startup.

    SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="XX:XX:XX:XX:XX:XX", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
  • The network in the custom image is not configured to get an IP address through DHCP. For example, if the custom image is configured with a static IP address, a new ECS instance created from this image also uses that static IP address. This can cause an IP address conflict or place the instance in the wrong subnet, which makes the network unavailable.

Solutions

Note
  • If you perform risky operations, such as modifying an instance or its data, ensure that the instance has disaster recovery and fault tolerance capabilities to protect your data.

  • If you modify the configuration or data of an instance, such as an ECS or RDS instance, we recommend that you create a snapshot or enable a feature such as RDS log backup before you start.

  • If you have granted permissions or submitted security information, such as logon credentials on the Alibaba Cloud platform, change them promptly.

The solution varies based on the cause. To prevent this issue, check the network configuration of the source instance before you create the custom image. Follow these steps:

Note

Before you modify a file in the following steps, back up the configuration file or create a snapshot of the ECS instance.

  1. Remotely log on to the source ECS instance.

  2. Run the following command to confirm that the configuration file does not contain the GATEWAY parameter. If the parameter exists, comment it out.

    Note

    The GATEWAY parameter may vary based on the environment. Use the value that is specific to your environment.

    cat /etc/sysconfig/network

    The system displays output similar to the following.

    # Created by anaconda
  3. Check the following configuration file. If it contains network rules, delete the rules for the corresponding NIC.

    /etc/udev/rules.d/70-persistent-net.rules
  4. Run the following command to check the configuration file.

    cat /etc/sysconfig/network-scripts/ifcfg-eth0

    The system displays output similar to the following. Confirm that the output contains the three configurations shown and does not contain parameters for a static IP address or a GATEWAY. If these parameters exist, comment them out.

    DEVICE=eth0
    BOOTPROTO=dhcp
    ONBOOT=yes

Applicable to

  • Elastic Compute Service