1、service network restart报错,具体报错如下:
Restarting network (via systemctl): Job for network.service failed because the control process exited with error code. See "systemctl status network.service" and "journalctl -xe" for details.
根据提示,执行:systemctl status network.service 查看具体报错信息,也可查看cat /var/log/messages|grep network
Jun 23 22:46:32 localhost systemd: Starting LSB: Bring up/down networking...
Jun 23 22:46:32 localhost NetworkManager[1006]: ifcfg-rh: parsing /etc/sysconfig/network-scripts/ifcfg-lo ...
Jun 23 22:46:32 localhost network: Bringing up loopback interface: [ OK ]
Jun 23 22:46:32 localhost network: Bringing up interface eno16777736: Error: Connection activation failed: Connection 'eno16777736' is not available on the device eno16777736 at this time.
Jun 23 22:46:32 localhost network: [FAILED]
Jun 23 22:46:32 localhost network: RTNETLINK answers: File exists
Jun 23 22:46:32 localhost network: RTNETLINK answers: File exists
Jun 23 22:46:32 localhost network: RTNETLINK answers: File exists
Jun 23 22:46:32 localhost network: RTNETLINK answers: File exists
Jun 23 22:46:32 localhost network: RTNETLINK answers: File exists
Jun 23 22:46:32 localhost network: RTNETLINK answers: File exists
Jun 23 22:46:32 localhost network: RTNETLINK answers: File exists
Jun 23 22:46:32 localhost network: RTNETLINK answers: File exists
Jun 23 22:46:32 localhost network: RTNETLINK answers: File exists
Jun 23 22:46:32 localhost systemd: network.service: control process exited, code=exited status=1
Jun 23 22:46:32 localhost systemd: Failed to start LSB: Bring up/down networking.
Jun 23 22:46:32 localhost systemd: Unit network.service entered failed state.
Jun 23 22:46:32 localhost systemd: network.service failed.
解决办法:
Jun 23 22:53:33 localhost systemd: Starting LSB: Bring up/down networking...
Jun 23 22:53:33 localhost network: Bringing up loopback interface: [ OK ]
Jun 23 22:53:33 localhost network: Bringing up interface eno16777736: ipcalc: bad netmask: 225.225.225.0
Jun 23 22:53:33 localhost network: ipcalc: bad netmask: 225.225.225.0
Jun 23 22:53:33 localhost network: ipcalc: bad netmask: 225.225.225.0
Jun 23 22:53:35 localhost network: Error: an inet prefix is expected rather than "192.168.137.15/".
Jun 23 22:53:35 localhost network: ERROR : [/etc/sysconfig/network-scripts/ifup-eth] Error adding address 192.168.137.15 for eno16777736.
Jun 23 22:53:35 localhost /etc/sysconfig/network-scripts/ifup-eth: Error adding address 192.168.137.15 for eno16777736.
Jun 23 22:53:35 localhost network: bind: Cannot assign requested address
Jun 23 22:53:35 localhost network: Error: an inet prefix is expected rather than "192.168.137.15/".
Jun 23 22:53:35 localhost NET[3750]: /etc/sysconfig/network-scripts/ifup-post : updated /etc/resolv.conf
Jun 23 22:53:35 localhost network: [ OK ]
Jun 23 22:53:35 localhost network: RTNETLINK answers: File exists
Jun 23 22:53:35 localhost network: RTNETLINK answers: File exists
Jun 23 22:53:35 localhost network: RTNETLINK answers: File exists
Jun 23 22:53:35 localhost network: RTNETLINK answers: File exists
Jun 23 22:53:35 localhost network: RTNETLINK answers: File exists
Jun 23 22:53:35 localhost network: RTNETLINK answers: File exists
Jun 23 22:53:35 localhost network: RTNETLINK answers: File exists
Jun 23 22:53:35 localhost network: RTNETLINK answers: File exists
Jun 23 22:53:35 localhost network: RTNETLINK answers: File exists
Jun 23 22:53:35 localhost systemd: Started LSB: Bring up/down networking.
修改/etc/sysconfig/network-scripts/
[root@localhost network-scripts]# cat ifcfg-eno16777736
HWADDR=00:0C:29:0D:ED:88
TYPE=Ethernet
BOOTPROTO=static
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
NAME=eno16777736
UUID=52e0ff70-7e89-46ae-8f7a-699099c36f5e
ONBOOT=yes
IPADDR=192.168.137.15
GATEWAY=192.168.137.2
NETMASK=255.255.255.0
DNS1=192.168.1.1
然后重启服务:service network restart 问题解决。
[root@localhost network-scripts]# ping www.baidu.com
PING www.a.shifen.com (220.181.112.244) 56(84) bytes of data.
64 bytes from 220.181.112.244: icmp_seq=1 ttl=128 time=26.7 ms
64 bytes from 220.181.112.244: icmp_seq=2 ttl=128 time=25.0 ms
64 bytes from 220.181.112.244: icmp_seq=3 ttl=128 time=24.8 ms
64 bytes from 220.181.112.244: icmp_seq=4 ttl=128 time=24.6 ms
64 bytes from 220.181.112.244: icmp_seq=5 ttl=128 time=27.0 ms
64 bytes from 220.181.112.244: icmp_seq=6 ttl=128 time=25.1 ms
64 bytes from 220.181.112.244: icmp_seq=7 ttl=128 time=27.8 ms
64 bytes from 220.181.112.244: icmp_seq=8 ttl=128 time=30.4 ms
^C
--- www.a.shifen.com ping statistics ---
8 packets transmitted, 8 received, 0% packet loss, time 7014ms
rtt min/avg/max/mdev = 24.662/26.459/30.403/1.848 ms