How Do I Make the Changed DHCP Lease Time of a Subnet Take Effect Immediately?
Scenario
After you change the DHCP lease time on the console, the change will be applied when the DHCP lease of an instance (such as ECS) is renewed. You can manually renew the lease or wait for the system to do it. Renewing lease will not change the IP address of the instance.
- If you want the change to be applied immediately, manually renew the lease. Manual renewal will interrupt services.
- If you do not want the change to be applied immediately, wait for the system to renew the DHCP lease automatically. The system renews the lease for the first time when half of the current lease time is left. If the renewal fails, the system attempts to renew the lease again when one eighth of the current lease time is left. If the renewal still fails, the IP address of the instance will be released after the current lease expires. To prevent the IP address from being released, manually renew the lease.
For details about the DHCP lease renewal, see Table 1.
Applied Immediately |
How to Renew |
Description |
---|---|---|
Yes |
Manually |
You can manually renew the DHCP lease of the instance by referring to Viewing and Renewing the DHCP Lease (Windows ECS) or Viewing and Updating the DHCP Lease (Linux ECS). You can also restart the instance to make the new DHCP release to be applied immediately.
NOTICE:
If you renew the DHCP lease manually, the IP address of the instance will be released, and a new IP address will be assigned when the new lease is applied. This may cause service interruption. |
No |
Automatically |
You can wait for the new lease to be applied automatically.
Suppose the DHCP lease time of an ECS is 30 days, and the lease will expire on January 30, 2024. If you change the DHCP lease time to 10 days on January 2, 2024:
|
Viewing and Renewing the DHCP Lease (Windows ECS)
- After you change the DHCP lease time on the console, log in to the ECS whose lease you want to renew.
- Enter cmd in the search box to open the CLI.
- View the expiration time of the current DHCP lease:
- Renew the DHCP lease:
- Check the new DHCP lease expiration time:
Viewing and Updating the DHCP Lease (Linux ECS)
- After you change the DHCP lease time on the console, log in to the ECS whose lease you want to renew.
- Check whether the client that provides the DHCP service is dhclient:
ps -ef | grep dhclient
- If information similar to the following is displayed, the dhclient process exists and the client is dhclient. The lease file following the -lf parameter contains lease information.
[root@ecs-A ~]# ps -ef | grep dhclient root 580 526 0 18:49 ? 00:00:00 /sbin/dhclient -d -q -sf /usr/libexec/nm-dhcp-helper -pf /var/run/dhclient-eth0.pid -lf /var/lib/NetworkManager/dhclient-5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03-eth0.lease -cf /var/lib/NetworkManager/dhclient-eth0.conf eth0 root 1512 1470 0 18:50 pts/0 00:00:00 grep --color=auto dhclient
- If the dhclient process does not exist, this procedure may not be applicable. In this case, you need to search for the operation commands of the corresponding DHCP client.
- If information similar to the following is displayed, the dhclient process exists and the client is dhclient. The lease file following the -lf parameter contains lease information.
- View the latest DHCP lease information in the lease file obtained in 2:
cat lease File name
Example command:
cat /var/lib/NetworkManager/dhclient-5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03-eth0.lease
Information similar to the following is displayed. The lease file contains historical DHCP lease information, and the information following the last lease is about the latest DHCP lease.[root@ecs-A ~]# cat /var/lib/NetworkManager/dhclient-5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03-eth0.lease lease { interface "eth0"; fixed-address 172.16.0.54; option subnet-mask 255.255.255.0; option dhcp-lease-time 108000000; option routers 172.16.0.1; option dhcp-message-type 5; option dhcp-server-identifier 172.16.0.254; option domain-name-servers 100.125.1.250,100.125.64.250; option interface-mtu 1500; option dhcp-renewal-time 54000000; option dhcp-rebinding-time 94500000; option rfc3442-classless-static-routes 0,172,16,0,1,32,169,254,169,254,172,16,0,1; option broadcast-address 172.16.0.255; option host-name "host-172-16-0-54"; option domain-name "openstacklocal"; renew 3 2025/06/18 21:46:42; rebind 3 2027/01/20 04:46:44; expire 5 2027/06/25 10:46:44; } lease { interface "eth0"; fixed-address 172.16.0.54; option subnet-mask 255.255.255.0; option routers 172.16.0.1; option dhcp-lease-time 108000000; option dhcp-message-type 5; option domain-name-servers 100.125.1.250,100.125.64.250; option dhcp-server-identifier 172.16.0.254; option interface-mtu 1500; option dhcp-renewal-time 54000000; option broadcast-address 172.16.0.255; option rfc3442-classless-static-routes 0,172,16,0,1,32,169,254,169,254,172,16,0,1; option dhcp-rebinding-time 94500000; option host-name "host-172-16-0-54"; option domain-name "openstacklocal"; renew 3 2025/08/20 23:57:15; rebind 3 2027/01/20 04:50:00; expire 5 2027/06/25 10:50:00; }
- Release the IP address of the ECS:
- Obtain the new DHCP lease:
- View the latest DHCP lease information in the lease file obtained in 2:
cat lease File name
Example command:
cat /var/lib/NetworkManager/dhclient-5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03-eth0.lease
Information similar to the following is displayed. The lease file contains historical DHCP lease information, and the information following the last lease is about the latest DHCP lease.[root@ecs-A ~]# cat /var/lib/NetworkManager/dhclient-5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03-eth0.lease lease { interface "eth0"; fixed-address 172.16.0.54; option subnet-mask 255.255.255.0; option dhcp-lease-time 108000000; option routers 172.16.0.1; option dhcp-message-type 5; option dhcp-server-identifier 172.16.0.254; option domain-name-servers 100.125.1.250,100.125.64.250; option interface-mtu 1500; option dhcp-renewal-time 54000000; option dhcp-rebinding-time 94500000; option rfc3442-classless-static-routes 0,172,16,0,1,32,169,254,169,254,172,16,0,1; option broadcast-address 172.16.0.255; option host-name "host-172-16-0-54"; option domain-name "openstacklocal"; renew 3 2025/08/20 23:57:15; rebind 3 2027/01/20 04:50:00; expire 5 2027/06/25 10:50:00; } lease { interface "eth0"; fixed-address 172.16.0.54; option subnet-mask 255.255.255.0; option routers 172.16.0.1; option dhcp-lease-time 108000000; option dhcp-message-type 5; option domain-name-servers 100.125.1.250,100.125.64.250; option dhcp-server-identifier 172.16.0.254; option interface-mtu 1500; option dhcp-renewal-time 54000000; option broadcast-address 172.16.0.255; option rfc3442-classless-static-routes 0,172,16,0,1,32,169,254,169,254,172,16,0,1; option dhcp-rebinding-time 94500000; option host-name "host-172-16-0-54"; option domain-name "openstacklocal"; renew 4 2025/07/03 00:34:04; rebind 3 2027/01/20 04:52:43; expire 5 2027/06/25 10:52:43; }Sub-eni
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot