虚拟私有云 VPC-修改子网的DHCP租约时间如何立即生效?:查看/更新DHCP租约到期时间(Linux系统)
查看/更新DHCP租约到期时间(Linux系统)
- 在控制台修改子网DHCP租约时间后,登录待刷新租约的云服务器。
- 执行以下命令,确认提供DHCP服务的客户端为dhclient。
- 回显类似如下信息,表示存在dhclient对应进程,说明客户端是dhclient。其中-lf参数后,类型为lease的文件中存有租约信息。
[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
- 如果不存在dhclient进程,则本文档可能不适用,请您查找对应DHCP客户端的操作指令。
- 回显类似如下信息,表示存在dhclient对应进程,说明客户端是dhclient。其中-lf参数后,类型为lease的文件中存有租约信息。
- 执行以下命令,查看2的lease文件中当前DHCP租约信息。
cat lease文件名称
命令示例:
cat /var/lib/NetworkManager/dhclient-5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03-eth0.lease
回显类似如下信息,lease文件中会保存历史DHCP租约信息,最后一个是最新的DHCP租约信息。[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; }
- 执行以下命令,释放当前云服务器的IP地址。
- 执行以下命令,获取新的DHCP租约。
- 执行以下命令,查看2的lease文件中最新的DHCP租约信息。
cat lease文件名称
命令示例:
cat /var/lib/NetworkManager/dhclient-5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03-eth0.lease
回显类似如下信息,lease文件中会保存历史DHCP租约信息,最后一个是更新后的DHCP租约信息。[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