在 Debian 上优化 DHCP(通常是 ISC DHCP Server,即 isc-dhcp-server)性能,可以从配置、系统、网络、内核几个层面来做。下面按实用程度给你一套优化思路。
过短的 lease 会增加请求量,过长会拖慢地址回收。
default-lease-time 3600; # 默认 1 小时
max-lease-time 86400; # 最大 1 天
min-lease-time 600;
✅ 建议:
authoritative避免不必要的延迟和冲突处理:
authoritative;
DHCP 默认日志很详细,影响性能。
编辑 /etc/dhcp/dhcpd.conf:
log-facility local7;
在 /etc/rsyslog.conf 中限制:
local7.* /var/log/dhcpd.log
# 关闭 debug
或:
systemctl edit isc-dhcp-server
加:
Environment=DHCPD_LOG_FACILITY=local7
ping-check 谨慎开启ping-check true; # 默认
高负载时可关闭:
ping-check false;
⚠️ 关闭可能分配已被使用的 IP(风险)
one-lease-per-client避免频繁换 IP:
one-lease-per-client true;
避免超大地址池:
subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.100 192.168.1.200;
}
大网络建议:
systemctl edit isc-dhcp-server
[Service]
Nice=-10
CPUWeight=80
租约文件频繁写:
lease-file-name "/var/lib/dhcp/dhcpd.leases";
建议:
减少 CPU 争抢:
systemctl disable bluetooth
systemctl disable avahi-daemon
sysctl -w net.core.rmem_max=26214400
sysctl -w net.core.wmem_max=26214400
ethtool -G eth0 rx 4096 tx 4096
ethtool -K eth0 gro on
dhcpd 实例dhcpd -f -cf /etc/dhcp/dhcpd1.conf eth0
如果 DHCP 压力非常大(>5k 客户端):
apt install kea
journalctl -u isc-dhcp-server
ss -lunp | grep :67
tcpdump -i eth0 port 67
authoritative;
default-lease-time 3600;
max-lease-time 86400;
ping-check false;
one-lease-per-client true;
log-facility local7;
subnet 192.168.10.0 netmask 255.255.255.0 {
range 192.168.10.100 192.168.10.250;
option routers 192.168.10.1;
option domain-name-servers 8.8.8.8;
}
如果你能提供:
我可以给你针对性优化方案。