Why Is the ECS IP Address Lost After the System Time Changes?
Symptom
After the system time changes, an exclamation mark (!) is displayed for the NIC, and the ECS cannot connect to the Internet.
Scenarios
- The operations described in this section apply to ECSs running CentOS 7 or EulerOS that use DHCP to obtain IP addresses.
- The default DHCP lease time is 24 hours. Specific scenarios may be different.
Root Cause
DHCP session process
A typical DHCP session includes DHCP discover, DHCP offer, DHCP request, and DHCP acknowledgment, as shown in Figure 1.
- DHCP Discover
The DHCP client sends a broadcast message on the physical subnet to search for available DHCP servers. The network administrator can configure a local route to forward DHCP packets to DHCP servers on another subnet. The client generates a UDP packet whose destination address is 255.255.255.255 or the specific subnet broadcast address.
- DHCP Offer
When a DHCP server receives an IP address lease request from the client, the DHCP server provides an IP address lease and reserves an IP address for the client, and then sends a DHCPOFFER message to the client through unicast. This message contains the MAC address of the client, the IP address that the server is providing, the subnet mask, the lease duration, and the IP address of the DHCP server making the offer.
- DHCP Request
In response to the DHCP offer, the client replies with a DHCPREQUEST message that contains the IP address of the server making the offer, which is a broadcast informing the server that it accepts the offer. When other DHCP servers receive this message, they withdraw any offers they have made to the client and return the offered IP addresses to the pool of available addresses. A client can receive DHPC offers from multiple servers, but it will accept only one DHCP offer.
- DHCP Acknowledge (DHCP ACK)
When the DHCP server receives the DHCPREQUEST message from the client, the configuration process enters its final phase. The acknowledgement phase involves sending a DHCPACK packet to the client. This packet contains the lease duration and any other configuration information that may be requested by the client. At this point, the TCP/IP address configuration is complete.
Fault Locating
- View the DHCP request records of the client.
- The records show that dhclient renewed the IP address successfully on May 12. Since the system was manually changed, the actual time was April 26.
- The next renewal occurred 33,696 seconds (about 9 hours and 21 minutes) later, usually when half of the lease time has passed. That is, the next renewal occurred at around 21:21 on May 12.
You can also query the dhclient renewal information file for each successful renewal. Run the following command to query the path that saves the file. The file name is ended with .lease.
# ps -ef |grep dhclient
- Run the following command to check the system logs. The logs show that the system time was changed 5 hours and 14 minutes later after the renewal, and changed to April 26. This means the next renewal request would be sent in 16 days, but not 9 hours it should be. dhclient failed to renew the lease and just silently let the lease expire. After the lease expired, the IP address was withdrawn by the DHCP server. As a result, the IP address was lost.
# grep "Time has been changed" /var/log/messagesFigure 3 System logs
Solution
- Run dhclient manually to obtain the private IP address.
dhclient -r eth0
ifconfig eth0 down
ifconfig eth0 up
dhclient eth0
- Restart the ECS. The system time will restore and the system will obtain the IP address again.
- Enable time synchronization with an NTP server. For details, see Does HUAWEI CLOUD Provide the NTP Server and How Can I Configure It?
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.