主题
一、服务器租约
服务器的租约情况如下:
- 服务端租约记录 这是 /var/lib/dhcpd/dhcpd.leases (服务端)的记录 服务端记录显示的是每次DHCP事务的实际时间,而客户端记录中的 renew 、 rebind 、 expire 才是按50%、87.5%、100%计算的。
- 频繁的DHCP重新请求 从时间线看: 16:32:38 第一次获得租约、 16:32:51(13秒后)重新请求、 16:33:08(17秒后)再次请求、 这种短时间内多次请求可能因为:客户端网络重启、dhclient 命令手动执行、网络配置重新加载
- 租约时间重新计算 每次新的DHCP请求都会: 创建新的租约记录 重新计算租约时间(从当前时间 + 600秒) 生成新的 starts 和 ends 时间
- 正常的续租 vs 重新请求 正常续租应该是在租约50%时间(5分钟后)进行,但这里: 第一次:16:32:38 → 16:42:38(10分钟) 第二次:16:32:51 → 16:42:51(10分钟) 第三次:16:33:08 → 16:43:08(10分钟) 每次都是重新开始计算10分钟,而不是续租现有租约。
所以这不是标准的DHCP续租过程,而是客户端在短时间内多次重新获取IP地址的过程。正常的续租应该出现在租约进行到一半左右的时间点。
bash
[root@localhost dhcp]# cat /var/lib/dhcpd/dhcpd.leases
# The format of this file is documented in the dhcpd.leases(5) manual page.
# This lease file was written by isc-dhcp-4.2.5
# DHCP服务器唯一标识符(DUID)
server-duid "\000\001\000\0010\274\212\212\000\014)\222\364\334";
lease 192.168.42.150 { # IP地址192.168.42.150的租约记录
starts 5 2025/11/28 16:32:38; # 租约开始时间(周五16:32:38)
ends 5 2025/11/28 16:42:38; # 租约结束时间(周五16:42:38)
cltt 5 2025/11/28 16:32:38; # 客户端最后事务时间(客户端获得IP的时间)
binding state active; # 当前绑定状态:活跃(正在使用)
next binding state free; # 下一个绑定状态:空闲(租约到期后)
rewind binding state free; # 回滚绑定状态:空闲(用于故障恢复)
hardware ethernet 00:0c:29:f0:d2:96; # 客户端网卡的MAC地址
}
lease 192.168.42.150 { # 同一IP地址的第二次租约记录
starts 5 2025/11/28 16:32:51; # 租约开始时间(续租后)
ends 5 2025/11/28 16:42:51; # 租约结束时间(续租后)
cltt 5 2025/11/28 16:32:51; # 客户端最后事务时间(续租时间)
binding state active; # 当前绑定状态:活跃
next binding state free; # 下一个绑定状态:空闲
rewind binding state free; # 回滚绑定状态:空闲
hardware ethernet 00:0c:29:f0:d2:96; # 同一客户端的MAC地址
}
lease 192.168.42.150 { # 同一IP地址的第三次租约记录
starts 5 2025/11/28 16:33:08; # 租约开始时间(再次续租)
ends 5 2025/11/28 16:43:08; # 租约结束时间(再次续租)
cltt 5 2025/11/28 16:33:08; # 客户端最后事务时间(再次续租时间)
binding state active; # 当前绑定状态:活跃
next binding state free; # 下一个绑定状态:空闲
rewind binding state free; # 回滚绑定状态:空闲
hardware ethernet 00:0c:29:f0:d2:96; # 同一客户端的MAC地址
}1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34

二、客户端租约
客户端的租约情况如下:
1.对应关系
服务端的最后一次租约记录 对应 客户端的第一个租约记录。
2.验证对应关系的关键点:
IP地址相同:都是 192.168.42.150 过期时间一致:服务端的 ends 16:43:08 = 客户端的 expire 16:43:08 续租时间符合规律:客户端的 renew 16:37:40 大约是服务端 starts 16:33:08 的5分钟后(50%)
bash
[root@localhost ~]# cat /var/lib/dhclient/dhclient.leases # 查看客户端DHCP租约文件
lease { # 租约记录开始
interface "ens33"; # 网络接口名称
fixed-address 192.168.42.150; # 分配给客户端的固定IP地址
option subnet-mask 255.255.255.0; # 子网掩码
option routers 192.168.42.2; # 默认网关地址
option dhcp-lease-time 600; # DHCP租约时间(600秒=10分钟)
option dhcp-message-type 5; # DHCP消息类型(5=ACK确认)
option domain-name-servers 8.8.8.8,114.114.114.114; # DNS服务器地址
option dhcp-server-identifier 192.168.42.128; # DHCP服务器的IP地址
option domain-name "example.com"; # 域名后缀
renew 5 2025/11/28 16:37:40; # 续租时间(T1时间点,租约50%时)
rebind 5 2025/11/28 16:41:53; # 重新绑定时间(T2时间点,租约87.5%时)
expire 5 2025/11/28 16:43:08; # 租约过期时间
}
lease { # 第二个租约记录(续租后)
interface "ens33"; # 网络接口名称
fixed-address 192.168.42.150; # 续租后的IP地址(保持不变)
option subnet-mask 255.255.255.0; # 子网掩码
option routers 192.168.42.2; # 默认网关地址
option dhcp-lease-time 600; # DHCP租约时间
option dhcp-message-type 5; # DHCP消息类型
option domain-name-servers 8.8.8.8,114.114.114.114; # DNS服务器地址
option dhcp-server-identifier 192.168.42.128; # DHCP服务器地址
option domain-name "example.com"; # 域名后缀
renew 5 2025/11/28 16:41:58; # 新的续租时间点
rebind 5 2025/11/28 16:46:25; # 新的重新绑定时间点
expire 5 2025/11/28 16:47:40; # 新的租约过期时间
}1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
