在 Debian 10 (buster) 上,我使用 MAC 地址配置了 DHCP,但它不起作用。
当我使用“ifup”命令时,结果是错误的。
我需要配置此 IP:192.168.251.11
,但 DHCP 将此 IP 属性为:192.168.251.143
使用 ifup 的示例
# ifup eno1
Internet Systems Consortium DHCP Client 4.4.1
Copyright 2004-2018 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/
Listening on LPF/eno1/b8:cb:29:dd:b2:1e
Sending on LPF/eno1/b8:cb:29:dd:b2:1e
Sending on Socket/fallback
DHCPDISCOVER on eno1 to 255.255.255.255 port 67 interval 8
DHCPDISCOVER on eno1 to 255.255.255.255 port 67 interval 12
DHCPOFFER of 192.168.251.143 from 192.168.251.2
DHCPREQUEST for 192.168.251.143 on eno1 to 255.255.255.255 port 67
DHCPACK of 192.168.251.143 from 192.168.251.2
bound to 192.168.251.143 -- renewal in 1512 seconds.
dhclient 示例
IP正确。
# dhclient -v eno1
Internet Systems Consortium DHCP Client 4.4.1
Copyright 2004-2018 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/
Listening on LPF/eno1/b8:cb:29:dd:b2:1e
Sending on LPF/eno1/b8:cb:29:dd:b2:1e
Sending on Socket/fallback
DHCPREQUEST for 192.168.251.11 on eno1 to 255.255.255.255 port 67
DHCPREQUEST for 192.168.251.11 on eno1 to 255.255.255.255 port 67
DHCPACK of 192.168.251.11 from 192.168.251.2
bound to 192.168.251.11 -- renewal in 8182 seconds.
我想了解差异并解决问题。当服务器重新启动时,会分配错误的 IP。
感谢您的帮助和解释。
答案1
我找到了解决方案,但没有找到答案。
→ 原始解决方案和更多解释在这里:
https://superuser.com/a/1517961/863534
在/etc/dhcp/dhclient.conf
文件中,添加以下行:
send dhcp-client-identifier = hardware;
(可选)释放旧 IP:
ifdown interface1
dhcp -r interface1
删除所有接口(或特定接口)(不确定是否有用)
rm /var/lib/dhcp/dhclient.*
重启后服务器客户端将获取正确的IP。