我使用以下方法为我的 CentOS 7 服务器设置了一个静态 IP nmtui edit
(编辑的有线连接 1):
现在网络服务(systemctl restart network
)不再启动。
日志输出:
-- Unit network.service has begun starting up.
May 03 21:52:09 NIXSERVER NetworkManager[1010]: <info> [1588557129.6050] ifcfg-rh: update /etc/sysconfig/network-scripts/ifcfg-Wired_connection_1 (d8fac711-9114-32c9-a759-05fdeed28a6f,"Wired connection 1")
May 03 21:52:09 NIXSERVER NetworkManager[1010]: <warn> [1588557129.6094] ifcfg-rh: loading "/etc/sysconfig/network-scripts/ifcfg-eth0" fails: File '/etc/sysconfig/network-scripts/ifcfg-eth0' had neither TYPE nor DEVICE keys.
May 03 21:52:10 NIXSERVER network[12774]: Bringing up loopback interface: [ OK ]
May 03 21:52:10 NIXSERVER network[12774]: Bringing up interface Wired_connection_1: [ OK ]
May 03 21:52:10 NIXSERVER NetworkManager[1010]: <info> [1588557130.9329] audit: op="connection-activate" uuid="08e23dbd-9817-4247-98f3-4a149eecd390" name="enp0s25" result="fail" reason="No suitable device found for this connection."
May 03 21:52:10 NIXSERVER network[12774]: Bringing up interface enp0s25: Error: Connection activation failed: No suitable device found for this connection.
May 03 21:52:10 NIXSERVER network[12774]: [FAILED]
May 03 21:52:11 NIXSERVER NetworkManager[1010]: <warn> [1588557131.1644] ifcfg-rh: loading "/etc/sysconfig/network-scripts/ifcfg-eth0" fails: File '/etc/sysconfig/network-scripts/ifcfg-eth0' had neither TYPE nor DEVICE keys.
May 03 21:52:11 NIXSERVER network[12774]: Bringing up interface eth0: Could not load file '/etc/sysconfig/network-scripts/ifcfg-eth0'
May 03 21:52:11 NIXSERVER NetworkManager[1010]: <warn> [1588557131.3840] ifcfg-rh: loading "/etc/sysconfig/network-scripts/ifcfg-eth0" fails: File '/etc/sysconfig/network-scripts/ifcfg-eth0' had neither TYPE nor DEVICE keys.
May 03 21:52:11 NIXSERVER network[12774]: Could not load file '/etc/sysconfig/network-scripts/ifcfg-eth0'
May 03 21:52:11 NIXSERVER network[12774]: ERROR : [/etc/sysconfig/network-scripts/ifup-eth] Device does not seem to be present, delaying initialization.
May 03 21:52:11 NIXSERVER /etc/sysconfig/network-scripts/ifup-eth[13057]: Device does not seem to be present, delaying initialization.
May 03 21:52:11 NIXSERVER network[12774]: [FAILED]
May 03 21:52:11 NIXSERVER network[12774]: RTNETLINK answers: File exists
May 03 21:52:11 NIXSERVER network[12774]: RTNETLINK answers: File exists
May 03 21:52:11 NIXSERVER network[12774]: RTNETLINK answers: File exists
May 03 21:52:11 NIXSERVER network[12774]: RTNETLINK answers: File exists
May 03 21:52:11 NIXSERVER network[12774]: RTNETLINK answers: File exists
May 03 21:52:11 NIXSERVER network[12774]: RTNETLINK answers: File exists
May 03 21:52:11 NIXSERVER network[12774]: RTNETLINK answers: File exists
May 03 21:52:11 NIXSERVER network[12774]: RTNETLINK answers: File exists
May 03 21:52:11 NIXSERVER network[12774]: RTNETLINK answers: File exists
May 03 21:52:11 NIXSERVER systemd[1]: network.service: control process exited, code=exited status=1
May 03 21:52:11 NIXSERVER systemd[1]: Failed to start LSB: Bring up/down networking.
-- Subject: Unit network.service has failed
我是否遗漏了什么?此硬件仅连接了一个以太网。
命令输出nmcli -p dev
:
nmcli -p dev
====================================================
Status of devices
====================================================
DEVICE TYPE STATE CONNECTION
----------------------------------------------------
docker0 bridge connected docker0
enp12s0 ethernet connected Wired connection 1
enp11s0 ethernet unavailable --
lo loopback unmanaged --
答案1
日志显示 enp0s25 和 eth0,但这两个都不在您的 nmcli 列表中。您确定您编辑的连接正确吗?
我不会费心编辑内核参数,而是会追查并解决名称错误的原因。
/etc/sysconfig/network-scripts 文件的名称和内容是否正确?名称应与您的接口相对应:ifcfg-enp12s0 和 DEVICE=enp12s0。如果没有其他问题,systemctl restart NetworkManager
请检查。
在我的 Centos 7 服务器上,文件名、DEVICE=、nmcli 和 nmtui 都显示相同的内容 - 您不应该只有 3 个条目,而只有一个网卡。我会删除 2 个并修复一个。也许您更改了网卡或 bios 设置,导致 Centos 对其进行重命名。其他 2 个通用条目可能是无意中添加的。
答案2
看起来您正在尝试启动eth0
,但是您的设备名称是enp12s0
。
您可以biosdevname=0 net.ifnames=0
在内核命令行上设置旧的 NIC 名称。