我的教室里全是运行 CentOS 7 的计算机,只有一台计算机在启动时无法从 DHCP 服务器获取 IPv4 地址,因为当 DHCP 客户端尝试从 DHCP 服务器获取 IPv4 地址时,NIC 尚未启动。以下是 /var/log/messages 的输出:
Oct 14 14:15:03 a302 network: [ OK ]
Oct 14 14:15:03 a302 network: Activating interface enp0s25:
Oct 14 14:15:04 a302 kernel: IPv6: ADDRCONF(NETDEV_UP): enp0s25: link is not ready
...
Oct 14 14:15:09 a302 network: Determining IP information for enp0s25 ... failed; missing links. Is the cable OK?
Oct 14 14:15:09 a302 network: [FAILED]
当 NIC 准备就绪时,它将至少获得一个 IPv6 地址:
Oct 14 14:15:19 a302 kernel: e1000e: enp0s25 NIC Link is Up 100 Mbps Full Duplex, Flow Control: None
Oct 14 14:15:19 a302 kernel: e1000e 0000:00:19.0 enp0s25: Link Speed was downgraded by SmartSpeed
Oct 14 14:15:19 a302 kernel: e1000e 0000:00:19.0 enp0s25: 10/100 speed: disabling TSO
Oct 14 14:15:19 a302 kernel: IPv6: ADDRCONF(NETDEV_CHANGE): enp0s25: link becomes ready
Oct 14 14:15:19 a302 NetworkManager[938]: <info> (enp0s25): link connected
Oct 14 14:15:20 a302 avahi-daemon[770]: Registering new address record for fe80::223:aeff:fea4:76d3 on enp0s25.*.
Oct 14 14:15:21 a302 avahi-daemon[770]: Registering new address record for 2001:718:1c01:72:223:aeff:fea4:76d3 on enp0s25.*.
Oct 14 14:15:21 a302 avahi-daemon[770]: Withdrawing address record for fe80::223:aeff:fea4:76d3 on enp0s25.
/etc/sysconfig/network-scripts/ifcfg-enp0s25的内容如下:
# Generated by dracut initrd
DEVICE="enp0s25"
ONBOOT=yes
NETBOOT=yes
UUID="c2ed9174-ece7-4bea-9da4-0123456789ab"
IPV6INIT=yes
BOOTPROTO=dhcp
HWADDR="00:23:ae:11:22:33"
TYPE=Ethernet
NAME="enp0s25"
NM_CONTROLLED=no
IPV4_FAILURE_FATAL=yes
教室里的其他计算机毫无问题地获取了IPv4地址。
修改:问题出在 UTP 电缆上。有一对电线接错了。