Help Center> Elastic Cloud Server> Troubleshooting> Configuring the Network> Why Does My ECS Running CentOS 7 Fail to Obtain an IP Address Using dhclient?
Updated on 2022-02-22 GMT+08:00

Why Does My ECS Running CentOS 7 Fail to Obtain an IP Address Using dhclient?

Symptom

After an ECS was started, it failed to obtain an IP address because dhclient did not run.

Possible Causes

The possible causes are as follows:

  1. NetworkManager is not configured to start at boot.
  2. The target NIC is not managed by NetworkManager.

Constraints

The operations described in this section apply to ECSs running CentOS 7 series, EulerOS 2 series, or Ubuntu 18.04.

Solution

  1. Run the following command to check whether dhclient is running:

    # ps -ef |grep dhclient |grep -v grep

  2. If dhclient is not detected, run the following command to check whether NetworkManager is running:

    # systemctl status NetworkManager

    • If NetworkManager is in Active: inactive (dead) state, NetworkManager is not enabled. Run the following command to check whether NetworkManager is automatically started upon system startup:

      # systemctl is-enabled NetworkManager

      If the command output is disabled, run the following command to make NetworkManager start at boot automatically:

      # systemctl enable NetworkManager && systemctl start NetworkManager

    • If NetworkManager is in Active: active (running) state, run the following command to check whether the target NIC is managed by NetworkManager:

      # nmcli device status

      If the NIC is in unmanaged state, run the following command to make NetworkManager manage the NIC:

      # nmcli device set eth0 managed yes

  3. Restart NetworkManager.

    # systemctl restart NetworkManager

  4. Run the following command to check whether the private IP address can be allocated:

    # ip add