禁用并删除“NetworkManager”服务后,我无法启动 CentOS 7“网络”服务。当我检查网络服务状态时,出现以下错误:
#systemctl status network.service
network.service - LSB: Bring up/down networking
Loaded: loaded (/etc/rc.d/init.d/network)
Active: failed (Result: exit-code) since Fri 2015-01-16 22:30:46 GMT; 38s ago
Process: 4857 ExecStart=/etc/rc.d/init.d/network start (code=exited, status=1/FAILURE)
Jan 16 22:30:46 localhost.localdomain network[4857]: RTNETLINK answers: File exists
Jan 16 22:30:46 localhost.localdomain network[4857]: RTNETLINK answers: File exists
Jan 16 22:30:46 localhost.localdomain network[4857]: RTNETLINK answers: File exists
Jan 16 22:30:46 localhost.localdomain network[4857]: RTNETLINK answers: File exists
Jan 16 22:30:46 localhost.localdomain network[4857]: RTNETLINK answers: File exists
Jan 16 22:30:46 localhost.localdomain network[4857]: RTNETLINK answers: File exists
Jan 16 22:30:46 localhost.localdomain network[4857]: RTNETLINK answers: File exists
Jan 16 22:30:46 localhost.localdomain systemd[1]: network.service: control process exited, code=exited status=1
Jan 16 22:30:46 localhost.localdomain systemd[1]: Failed to start LSB: Bring up/down networking.
Jan 16 22:30:46 localhost.localdomain systemd[1]: Unit network.service entered failed state.
在早期的 CenOS 中,从“NetworkManager”服务切换到网络服务时似乎没有出现任何问题。您知道是什么原因导致的这个问题以及如何解决它吗?
注意:我使用 yum eras 来删除网络管理服务。
以下是所要求的附加信息:
/etc/sysconfig/network-script/ifcfg-enp8s0
TYPE=Ethernet
BOOTPROTO=dhcp
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
NAME=enp8s0
UUID=453a07fe-1b07-4f29-bc32-f2168e50706a
ONBOOT=yes
HWADDR=XXXXXXXXXXX
MACADDR=XXXXXXXXXX
PEERDNS=yes
PEERROUTES=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
/etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
/etc/resolv.conf
; generated by /usr/sbin/dhclient-script
search customer.marples.midcity.lan
nameserver 10.241.128.1
答案1
在 Centos7.0 中禁用 NetworkManager 会使为 NetworkManager 配置的 dhcp 客户端继续运行。这会导致服务启动RTNETLINK answers: File exists
时出现错误消息。network
陈旧的dhclient
进程还有额外的“好处”,那就是当租约到期时,您的dhclient
进程将被阻塞,因为它无法到达 NetWorkManager,从而删除您的 IP 地址。
如果您grep
找到它,您将看到它指向一个 NetWorkManager 配置文件。
[root@host ~]# ps -ef | grep dhc
root 1865 792 0 Apr28 ? 00:00:00 /sbin/dhclient -d -sf \
/usr/libexec/nm-dhcp-helper -pf /var/run/dhclient-eno1.pid -lf\
/var/lib/NetworkManager/dhclient-c96e56d3-a4c9-4a87-85ca-93dc0ca268f2-eno1.lease\
-cf /var/lib/NetworkManager/dhclient-eno1.conf eno1
因此,您可以做的是终止它dhclient
,然后才启动您的网络服务。
答案2
IP 冲突也会导致此错误。请尝试:systemctl stop network
,然后ifup eth0
。
答案3
我今天也在 CentOS 7.2 克隆虚拟机上遇到了这个问题。这就是我修复它的方法。
systemctl disable NetworkManager
systemctl enable network
通过命令找到接口的 MAC 地址/sbin/ifconfig -a
并将其附加到/etc/sysconfig/network-scripts/ifcfg-<interface_name>
。您可以对第一个接口使用以下命令。
nic_file=`ls /etc/sysconfig/network-scripts/ifcfg-e*`
ifconfig -a | grep ether | awk '{ print $2 }' | sed 's/.*/HWADDR=&/' >> ${nic_file}
然后reboot
重启服务器
答案4
如果您手动配置未连接到网络的接口,似乎也会发生这种情况。