Help Center/ Elastic Cloud Server/ User Guide (Kuala Lumpur Region)/ FAQs/ Network Configurations/ Others/ Why Can't I Use DHCP to Obtain a Private IP Address?
Updated on 2024-04-19 GMT+08:00

Why Can't I Use DHCP to Obtain a Private IP Address?

Symptom

You attempt to use DHCP to obtain a private IP address, but you cannot obtain the IP address.

  • For Linux, a private IP address cannot be assigned.
  • For Windows, a private IP address is changed to an IP address in the 169.254 network segment, which is different from the private IP address displayed on the ECS console.

You are advised to use a public image to create an ECS. All public images support DHCP continuous discovery mode.

Solution (Linux)

The following uses CentOS 7.2 as an example. For solutions about other OSs, see the corresponding help documentation.

  1. Log in to the ECS and run the following command:

    ps -ef | grep dhclient

  2. If the dhclient process does not exist, restart the NIC or run any of the following commands to initiate a DHCP request:

    dhclient eth0, ifdown eth0 + ifup eth0, or dhcpcd eth0

  3. If the DHCP client does not send any requests for a long time, for example, the issue recurs after the NIC is restarted, do the following:
    1. Run the following command to configure a static IP:

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

      BOOTPROTO=static
      IPADDR=192.168.1.100 #IP address (modified)
      NETMASK=255.255.255.0 #Mask (modified)
      GATEWAY=192.168.1.1 #Gateway IP address (modified)
    2. Restart the ECS to make the network settings take effect.
    3. Select an image in which DHCP runs stably.
  4. If the fault persists, obtain the messages in /var/log/messages on the affected ECS, use the MAC address of the affected NIC to filter the desired log, and check whether there is any process that prevents DHCP from obtaining an IP address.
  5. If the fault persists, contact technical support.

Solution (Windows)

The following uses Windows 2012 as an example. For solutions about other OSs, see the corresponding help documentation.

  1. Right-click a local area connection and choose Disable from the shortcut menu. Then, choose Enable.

  2. If the DHCP client does not send any requests for a long time, for example, the issue recurs after the NIC is restarted, do the following:
    1. Right-click Local Area Connection and choose Properties from the shortcut menu.
    2. In the displayed dialog box, select Internet Protocol Version 4 (TCP/IPv4), click Properties, and modify parameter settings.

    3. Restart the ECS to make the network settings take effect.
  3. If the fault persists, contact technical support.