Overview
By default, Elastic Compute Service (ECS) instances use the Dynamic Host Configuration Protocol (DHCP) to automatically assign IP addresses to Elastic Network Interfaces (ENIs) and retrieve IP address lease expiration times. Normally, the dhclient process on a Linux instance periodically updates the lease expiration time with the DHCP server to ensure the availability of the instance's IP address. The following issues can cause the DHCP service on a Linux instance to malfunction and lead to network connectivity failure:
The network interface configuration file contains errors.
The
dhclientprocess for the network interface is not running.
This topic describes how to check the DHCP configuration of a local network interface and resolve related issues.
Detailed information
If you perform risky operations, such as modifying instances or data, ensure data security by understanding the disaster recovery and fault tolerance capabilities of your instances.
Before you modify the configurations or data of instances such as ECS and RDS, create snapshots or enable features such as RDS log backup.
If you have granted permissions or submitted security information such as logon credentials on the Alibaba Cloud platform, change them promptly.
Remotely log on to the Linux instance. For more information, see Overview of connection methods for ECS instances.
NoteIf you cannot use the Secure Shell Protocol (SSH) to remotely log on to a Linux instance, see Troubleshoot remote logon failures to Linux instances over SSH.
To avoid data security risks from incorrect operations, create a snapshot to back up the ECS instance. For more information about how to create a snapshot, see Create a snapshot.
On the Linux instance, run the following command to check and record the existing local network interfaces.
ls -al /sys/class/net/The command output is similar to the following figure. In the output, eth0 is the local network interface. This example shows one local network interface. If you have added secondary ENIs to your ECS instance, the actual output may vary.

If the Linux instance has only one local network interface, continue with the following steps. If the instance has multiple local network interfaces, perform Steps 5 to 8 for each interface.
On the Linux instance, run the following command to check the configuration file of the local network interface.
cat /etc/sysconfig/network-scripts/ifcfg-[$Eth]Note[$Eth] is a placeholder for the name of the local network interface. Replace it with the actual interface name, such as eth0.
The output is similar to the following. In the output,
BOOTPROTO=dhcpindicates that the local network interface uses DHCP to obtain an IP address.# Created by cloud-init on instance boot automatically, do not edit. # If you don't want cloud-init generated automatically, you can disable it in /etc/cloud/cloud.cfg # For more information, please refer to: https://www.alibabacloud.com/help/document_detail/57803.html # BOOTPROTO=dhcp DEVICE=[$Eth] ONBOOT=yes STARTMODE=auto TYPE=Ethernet USERCTL=noProceed based on the following conditions:
The local network interface does not use DHCP to obtain an IP address: Confirm the reason for this configuration with your server administrator. If DHCP is not required, the remaining steps in this topic do not apply.
The local network interface uses DHCP to obtain an IP address: Compare the configuration file on your Linux instance with the preceding example to check for spelling errors. Then, proceed to the next step.
On the Linux instance, run the following command to check the status of the
dhclientprocess for the corresponding network interface.ps aux | grep dhclient | grep [$Eth]Proceed based on the following conditions:
The command returns the
dhclientprocess for the local network interface. This indicates that the DHCP service for this interface is normal.
NoteThis example uses the eth0 interface. The actual output may vary.
If the command returns no output, the
dhclientprocess is not running. Proceed to the next step.
On the Linux instance, run the following command to restart the
dhclientprocess for the corresponding network interface.ifup [$Eth]Run the following command again to confirm that the
dhclientprocess for the corresponding network interface is running.ps aux | grep dhclient | grep [$Eth]
References
Applicable to
Elastic Compute Service