在 Debian 上 DHCP 获取 IP 失败 是很常见的问题,原因通常可以分为 配置问题、服务问题、网络/驱动问题、以及环境限制。下面按最常见原因 → 排查方法给你一个系统性的思路。
DHCP 只会对 已启用(UP) 的网卡生效。
检查:
ip link
如果看到:
eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> ...
或 state DOWN,说明网卡没起来。
解决:
ip link set eth0 up
Debian 默认使用 ifupdown 时,配置应是:
auto eth0
iface eth0 inet dhcp
常见错误:
static 却没配 IPauto eth0ens33)应用配置:
ifdown eth0; ifup eth0
很多 DHCP 失败是因为 ifupdown 和 NetworkManager 混用。
检查:
systemctl status NetworkManager
如果是桌面版 Debian,推荐用:
nmcli device show
nmcli connection up eth0
Debian 常用 DHCP 客户端:
dhclientdhcpcd检查是否安装:
which dhclient
which dhcpcd
手动测试(非常有用地排查):
dhclient -v eth0
如果卡在:
DHCPDISCOVER on eth0 to 255.255.255.255 port 67
说明 网络层或服务器有问题。
验证:
ethtool eth0
看 Link detected: yes
DHCP 使用:
检查:
iptables -L
nft list ruleset
常见问题:
e1000 但驱动异常建议:
如果你用的是:
systemctl status systemd-networkd
配置应类似:
[Match]
Name=eth0
[Network]
DHCP=yes
可能实际是:
ens33enp0s3查看真实名字:
ip a
ip a
ip link
ethtool eth0
systemctl status NetworkManager
dhclient -v eth0
你可以直接贴出:
ip a/etc/network/interfacesdhclient -v eth0 的输出cat /etc/debian_version)我可以直接告诉你 是哪一步失败了,以及怎么改。