All Products
Search
Document Center

:What do I do if network service exceptions occur on a Linux ECS instance?

Last Updated:Mar 04, 2025

Network service exceptions on a Linux Elastic Compute Service (ECS) instance may cause issues, such as service unavailability, service performance degradation, and inability to connect to the instance. This topic describes how to resolve the network service exceptions.

Problem description

In this example, an ECS instance that runs Alibaba Cloud Linux 3.2104 LTS 64-bit is used. The following figure shows that the network service is in the inactive state.

image

The following figure shows that the network service cannot be found on the Linux ECS instance.

image

Solution

Check the network service status

  1. Connect to the Linux ECS instance.

    For more information, see Use Workbench to connect to a Linux instance over SSH. When network service exceptions occur, you may be unable to connect to the ECS instance. In this case, you can connect to the ECS instance by using Virtual Network Computing (VNC). For more information, see Connect to an instance by using VNC.

  2. Run a command to query the network service status. The command varies based on the operating system. The following table describes the commands used to query the network service status in different operating systems.

    Operating system

    Command used to check the network service status

    • Alibaba Cloud Linux 2

    • CentOS 7

    • Red Hat 7

    • Anolis 7

    • SUSE Linux 11, SUSE Linux 12, and SUSE Linux 15

    • openSUSE 15 and openSUSE 42

    sudo systemctl status network

    • CentOS 6

    • Red Hat 6

    sudo service network status

    • Alibaba Cloud Linux 3

    • CentOS 8

    • Red Hat 8

    • Anolis 8

    • Fedora 33, Fedora 34, and Fedora 35

    sudo systemctl status NetworkManager

    • Ubuntu 18, Ubuntu 20, and Ubuntu 22

    • Debian 12

    sudo systemctl status systemd-networkd

    • Ubuntu 14 and Ubuntu 16

    • Debian 8, Debian 9, Debian 10, and Debian 11

    sudo systemctl status networking

    The following figure shows that the network service runs as expected. If the status of the network service changes to inactive (dead), the network service is not activated. To resolve the issue, restart the network service. If the "service could not be found" error message appears, the network service does not exist, which may be caused by the uninstallation of relevant components. To resolve the issue, re-install the network service. image

Restart the network service

Run a command to restart the network service.

Important

The following table describes the commands used to restart the network service in different operating systems. Specific commands require an instance restart, which may cause business interruptions. We recommend that you restart the network service during off-peak hours.

Operating system

Command used to restart the network service

  • Alibaba Cloud Linux 2

  • CentOS 7

  • Red Hat 7

  • Anolis 7

  • SUSE Linux 11, SUSE Linux 12, and SUSE Linux 15

  • openSUSE 15 and openSUSE 42

sudo service network restart

or sudo systemctl restart network

  • CentOS 6

  • Red Hat 6

sudo service network restart

  • Alibaba Cloud Linux 3

  • CentOS 8

  • Red Hat 8

  • Anolis 8

  • Fedora 33, Fedora 34, and Fedora 35

sudo systemctl restart NetworkManager or sudo reboot

  • Ubuntu 18, Ubuntu 20, and Ubuntu 22

  • Debian 12

sudo netplan apply

  • Ubuntu 14 and Ubuntu 16

  • Debian 8, Debian 9, Debian 10, and Debian 11

sudo systemctl restart networking or sudo reboot

After you restart the network service, run a command to check the network service status based on the operating system. If the service status is still abnormal, re-install the network service.

Re-install the network service

For example, the NetworkManager and network services are uninstalled from an Alibaba Cloud Linux 3 instance. You cannot obtain the IPv4 address of the instance by running the ip command, and the route command does not display routing information. In this case, if you attempt to download and install NetworkManager, an error message appears, which indicates that the network is unreachable. To resolve the issue, perform the following steps to re-install the network service.

image

Step 1: Obtain the network information of the ECS instance in the ECS console

Go to the Instance Details tab of the ECS instance in the ECS console to view the IP addresses of the instance.

  1. Log on to the ECS console.

  2. In the left-side navigation pane, choose Instances & Images > Instances.

  3. In the top navigation bar, select the region and resource group to which the resource belongs. 地域

  4. On the Instance page, find the ECS instance whose IP addresses you want to view and click the instance ID in the Instance ID/Name column. On the Instance Details tab, you can view the IP addresses of the instance.

    • IP addresses in the Configuration Information section:

      • The primary private IP address is 192.168.XX.XX.

  5. In the Configuration Information section, click the ID of the vSwitch of the instance. In the dialog box that appears, view the IPv4 CIDR block of the vSwitch.

As shown in the following figure, the IPv4 CIDR block of the vSwitch is 192.168.1.0/24. The primary private IPv4 address of the primary elastic network interface (ENI) is 192.168.1.201. The default gateway IP address is 192.168.1.253.

image

image

Step 2: Configure the network information for the instance

Connect to the Linux ECS instance and run the following commands to configure the IP address of the primary ENI and activate the primary ENI. Replace <IPv4 address of the primary ENI>, <Subnet mask>, and <Gateway IP address> with the actual IPv4 address, subnet mask, and gateway IP address that you obtained in the previous step.

sudo ip addr add <IPv4 address of the primary ENI>/<Subnet mask> dev eth0
sudo ip link set eth0 up
sudo ip route add default via <Gateway IP address> 

Example:

sudo ip addr add 192.168.1.201/24 dev eth0
sudo ip link set eth0 up
sudo ip route add default via 192.168.1.253

Step 3: Install NetworkManager

Download and install NetworkManager, and check its status after the installation is complete.

sudo yum install -y NetworkManager
sudo systemctl restart NetworkManager
sudo systemctl status NetworkManager

If the network service still fails to run after you re-install NetworkManager, run the following command to check the error logs for troubleshooting:

journalctl -u NetworkManager