![删除 NetworkManager 后无法启动 network.service](https://linux22.com/image/147292/%E5%88%A0%E9%99%A4%20NetworkManager%20%E5%90%8E%E6%97%A0%E6%B3%95%E5%90%AF%E5%8A%A8%20network.service.png)
我遇到这个问题,在互联网上找不到解决方案。我有一台带有 cpanel 和 whm 的 centos 7 服务器。我删除了NetworkManager并想打开network.service。然后我总是收到这个错误:
Job for network.service failed because the control process exited with error code. See "systemctl status network.service" and "journalctl -xe" for details.
[root@b1ca0 ~]# systemctl status network.service
● network.service - LSB: Bring up/down networking
Loaded: loaded (/etc/rc.d/init.d/network; bad; vendor preset: disabled)
Active: failed (Result: exit-code) since Thu 2019-01-31 10:34:31 EST; 8s ago
Docs: man:systemd-sysv-generator(8)
Process: 13807 ExecStart=/etc/rc.d/init.d/network start (code=exited, status=1/FAILURE)
Jan 31 10:34:31 b1ca0.k.dedikuoti.lt network[13807]: RTNETLINK answers: File exists
Jan 31 10:34:31 b1ca0.k.dedikuoti.lt network[13807]: RTNETLINK answers: File exists
Jan 31 10:34:31 b1ca0.k.dedikuoti.lt network[13807]: RTNETLINK answers: File exists
Jan 31 10:34:31 b1ca0.k.dedikuoti.lt network[13807]: RTNETLINK answers: File exists
Jan 31 10:34:31 b1ca0.k.dedikuoti.lt network[13807]: RTNETLINK answers: File exists
Jan 31 10:34:31 b1ca0.k.dedikuoti.lt network[13807]: RTNETLINK answers: File exists
Jan 31 10:34:31 b1ca0.k.dedikuoti.lt systemd[1]: network.service: control process exited, code=exited status=1
Jan 31 10:34:31 b1ca0.k.dedikuoti.lt systemd[1]: Failed to start LSB: Bring up/down networking.
Jan 31 10:34:31 b1ca0.k.dedikuoti.lt systemd[1]: Unit network.service entered failed state.
Jan 31 10:34:31 b1ca0.k.dedikuoti.lt systemd[1]: network.service failed.
[root@b1ca0 ~]# journalctl -u network
-- Logs begin at Thu 2019-01-31 10:30:42 EST, end at Thu 2019-01-31 10:43:29 EST. --
Jan 31 10:30:52 b1ca0.k.dedikuoti.lt systemd[1]: Starting LSB: Bring up/down networking...
Jan 31 10:30:53 b1ca0.k.dedikuoti.lt network[2894]: Bringing up loopback interface: [ OK ]
Jan 31 10:30:57 b1ca0.k.dedikuoti.lt network[2894]: Bringing up interface eth0: INFO : [ipv6_wait_tentative] Waiting for interface eth0 IPv6 address(es) to leave the 'tentative' state
Jan 31 10:30:57 b1ca0.k.dedikuoti.lt ipv6_wait_tentative[3335]: Waiting for interface eth0 IPv6 address(es) to leave the 'tentative' state
Jan 31 10:30:58 b1ca0.k.dedikuoti.lt network[2894]: INFO : [ipv6_wait_tentative] Waiting for interface eth0 IPv6 address(es) to leave the 'tentative' state
Jan 31 10:30:58 b1ca0.k.dedikuoti.lt ipv6_wait_tentative[3340]: Waiting for interface eth0 IPv6 address(es) to leave the 'tentative' state
Jan 31 10:30:59 b1ca0.k.dedikuoti.lt network[2894]: Error: inet prefix is expected rather than "2A02:7B40:5928:BA7::1/64".
Jan 31 10:30:59 b1ca0.k.dedikuoti.lt network[2894]: [ OK ]
Jan 31 10:31:00 b1ca0.k.dedikuoti.lt network[2894]: Bringing up interface prl_nettool-nm-eth0:
Jan 31 10:31:00 b1ca0.k.dedikuoti.lt dhclient[3406]: DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 7 (xid=0x5f0efd47)
Jan 31 10:31:07 b1ca0.k.dedikuoti.lt dhclient[3406]: DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 11 (xid=0x5f0efd47)
Jan 31 10:31:18 b1ca0.k.dedikuoti.lt dhclient[3406]: DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 11 (xid=0x5f0efd47)
Jan 31 10:31:29 b1ca0.k.dedikuoti.lt dhclient[3406]: DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 14 (xid=0x5f0efd47)
Jan 31 10:31:43 b1ca0.k.dedikuoti.lt dhclient[3406]: DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 18 (xid=0x5f0efd47)
Jan 31 10:32:01 b1ca0.k.dedikuoti.lt network[2894]: Determining IP information for eth0... failed.
Jan 31 10:32:01 b1ca0.k.dedikuoti.lt network[2894]: [FAILED]
Jan 31 10:32:01 b1ca0.k.dedikuoti.lt systemd[1]: network.service: control process exited, code=exited status=1
Jan 31 10:32:01 b1ca0.k.dedikuoti.lt systemd[1]: Failed to start LSB: Bring up/down networking.
Jan 31 10:32:01 b1ca0.k.dedikuoti.lt systemd[1]: Unit network.service entered failed state.
Jan 31 10:32:01 b1ca0.k.dedikuoti.lt systemd[1]: network.service failed.
Jan 31 10:33:29 b1ca0.k.dedikuoti.lt systemd[1]: Starting LSB: Bring up/down networking...
Jan 31 10:33:30 b1ca0.k.dedikuoti.lt network[13807]: Bringing up loopback interface: [ OK ]
Jan 31 10:33:30 b1ca0.k.dedikuoti.lt network[13807]: Bringing up interface eth0: RTNETLINK answers: File exists
Jan 31 10:33:30 b1ca0.k.dedikuoti.lt network[13807]: Error: inet prefix is expected rather than "2A02:7B40:5928:BA7::1/64".
Jan 31 10:33:30 b1ca0.k.dedikuoti.lt network[13807]: [ OK ]
Jan 31 10:33:30 b1ca0.k.dedikuoti.lt network[13807]: Bringing up interface prl_nettool-nm-eth0:
Jan 31 10:33:30 b1ca0.k.dedikuoti.lt dhclient[14056]: DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 7 (xid=0x612ef43c)
Jan 31 10:33:37 b1ca0.k.dedikuoti.lt dhclient[14056]: DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 13 (xid=0x612ef43c)
Jan 31 10:33:50 b1ca0.k.dedikuoti.lt dhclient[14056]: DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 14 (xid=0x612ef43c)
Jan 31 10:34:04 b1ca0.k.dedikuoti.lt dhclient[14056]: DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 14 (xid=0x612ef43c)
Jan 31 10:34:19 b1ca0.k.dedikuoti.lt dhclient[14056]: DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 9 (xid=0x612ef43c)
Jan 31 10:34:28 b1ca0.k.dedikuoti.lt dhclient[14056]: DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 3 (xid=0x612ef43c)
Jan 31 10:34:31 b1ca0.k.dedikuoti.lt network[13807]: Determining IP information for eth0... failed.
Jan 31 10:34:31 b1ca0.k.dedikuoti.lt network[13807]: [FAILED]
Jan 31 10:34:31 b1ca0.k.dedikuoti.lt network[13807]: RTNETLINK answers: File exists
Jan 31 10:34:31 b1ca0.k.dedikuoti.lt network[13807]: RTNETLINK answers: File exists
Jan 31 10:34:31 b1ca0.k.dedikuoti.lt network[13807]: RTNETLINK answers: File exists
Jan 31 10:34:31 b1ca0.k.dedikuoti.lt network[13807]: RTNETLINK answers: File exists
Jan 31 10:34:31 b1ca0.k.dedikuoti.lt network[13807]: RTNETLINK answers: File exists
Jan 31 10:34:31 b1ca0.k.dedikuoti.lt network[13807]: RTNETLINK answers: File exists
Jan 31 10:34:31 b1ca0.k.dedikuoti.lt network[13807]: RTNETLINK answers: File exists
Jan 31 10:34:31 b1ca0.k.dedikuoti.lt network[13807]: RTNETLINK answers: File exists
Jan 31 10:34:31 b1ca0.k.dedikuoti.lt network[13807]: RTNETLINK answers: File exists
Jan 31 10:34:31 b1ca0.k.dedikuoti.lt systemd[1]: network.service: control process exited, code=exited status=1
Jan 31 10:34:31 b1ca0.k.dedikuoti.lt systemd[1]: Failed to start LSB: Bring up/down networking.
Jan 31 10:34:31 b1ca0.k.dedikuoti.lt systemd[1]: Unit network.service entered failed state.
Jan 31 10:34:31 b1ca0.k.dedikuoti.lt systemd[1]: network.service failed.
DEVICE="eth0"
ONBOOT="yes"
BOOTPROTO="none"
HWADDR="00:00:59:28:0b:a7"
IPADDR="89.40.11.167"
NETMASK="255.255.255.255"
DHCPV6C="no"
IPV6_AUTOCONF="no"
IPV6INIT="yes"
IPV6ADDR="2A02:7B40:5928:BA7::1/64"
GATEWAY="169.254.0.1"
IPV6_DEFAULTGW="fe80::ffff:1:1"
[root@b1ca0 network-scripts]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:00:59:28:0b:a7 brd ff:ff:ff:ff:ff:ff
inet 89.40.11.167/32 brd 89.40.11.167 scope global eth0
valid_lft forever preferred_lft forever
inet6 2a02:7b40:5928:ba7::1/64 scope global
valid_lft forever preferred_lft forever
inet6 fe80::200:59ff:fe28:ba7/64 scope link
valid_lft forever preferred_lft forever
答案1
您可以尝试检查是否确实禁用了 NetworkManager:
# nmcli device status
# systemctl list-unit-files | grep NetworkManager
然后,您必须通过编辑相应的文件来检查接口中的 NM 参数。
Centos 使用一致的网络设备命名,因此如果您没有看到 ethX,您不必感到惊讶。
进入配置文件
# /etc/sysconfig/network-scripts/ifcfg-enpXsX
并输入以下内容:
NM_CONTROLLED="no"
我注意到您正在尝试使用 DHCP,我建议尝试使用静态 IP 地址。
例子:
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens160
UUID=666666666645664654654654
DEVICE=ens160
ONBOOT=yes
IPADDR=192.168.125.10
PREFIX=24
GATEWAY=192.168.125.1
DNS1=192.168.125.48
DNS2=8.8.8.8
IPV6_PRIVACY=no
NM_CONTROLLED=no
要设置 DNS,您必须修改文件 /etc/resolv.conf
然后尝试重新启动并启用网络服务:
systemctl restart network
systemctl enable network