当前这个系统是定制版的麒麟系统,不是centos,redhat,因此配置不一样

1.找到暂时没人用的网口

网卡.png

2.本次用的网口是4口 ifcfg-enp5s5

vi ifcfg-enp5s5
添加IP,NETMASK子网掩码,GATEWAY网关地址
编辑网络文件.png

3重启网络失败

3.1命令报错

命令使用错误

  1. [root@91centos91 ~]# service networt restart
  2. Redirecting to /bin/systemctl restart networt.service
  3. Failed to restart networt.service: Unit not found.

查看系统版本,linux系统应该使用systemctl命令重启网络

  1. [root@91centos91 ~]# cat /etc/redhat-release
  2. CentOS Linux release 7.8.2003 (Core)

应该使用systemctl重启网络命令

  1. [root@91centos91 ~]# systemctl restart network

3.2 文件配置错误

  1. Job for network.service failed because the control process exited with error code. See "systemctl status network.service" and "journalctl -xe" for details.

系统报错的信息,只要用 journalctl -xe 能看到网络启动的日志,多半是能看懂哪里报错了。这个日志里面还有系统的一些启动日志,https://www.cnblogs.com/leigepython/p/10302056.html,journalctl 命令的一些用法
1.对应网口的网络配置是错的,这一点是第一要排查的
2.1有一些没用但有ifcfg-xxx作为开头的网络配置文件,没用包括文件是空的,删了这些文件就可以。

2.2有几个网卡配置文件里的ip是现在用不上的,但扫描网络时会去尝试连接配置的ip,连不上,name重启网络也就失败了

下面大段的报错中这一段的意思就是,激活 enp5s5这个网口配置文件里的ip失败了,是因为里面配置了用不到的ip,网线也没插这个网口上,所以激活失败,激活失败也就会导致重启网络报错。
8月 09 11:33:23 91centos91 network[882]: 正在打开接口 enp5s5: 错误:连接激活失败:No suitable device found for this connection (device enp5s4 not available because profile is not compatible with device (mismatching interface name)).

  1. 8 09 11:33:17 91centos91 systemd[1]: Started Network Manager Wait Online.
  2. 8 09 11:33:17 91centos91 systemd[1]: Starting LSB: Bring up/down networking...
  3. 8 09 11:33:20 91centos91 network[882]: 正在打开环回接口: [ 确定 ]
  4. 8 09 11:33:21 91centos91 network[882]: 正在打开接口 enp1s0 [ 确定 ]
  5. 8 09 11:33:21 91centos91 network[882]: 正在打开接口 enp2s0 [ 确定 ]
  6. 8 09 11:33:22 91centos91 NetworkManager[707]: <info> [1628480002.4864] agent-manager: req[0x555b33c99b10, :1.27/nmcli-connect/0]: agent registered
  7. 8 09 11:33:22 91centos91 NetworkManager[707]: <info> [1628480002.4977] audit: op="connection-activate" uuid="86aa3eae-21fc-4fc7-bd5f-dc15cef08da3" name="enp5s4" result="fail" reason="No suitable device found for this connection (devic
  8. 8月 09 11:33:22 91centos91 network[882]: 正在打开接口 enp5s4: 错误:连接激活失败:No suitable device found for this connection (device enp5s4 not available because device has no carrier).
  9. 8月 09 11:33:22 91centos91 network[882]: [失败]
  10. 8月 09 11:33:23 91centos91 NetworkManager[707]: <info> [1628480003.3913] agent-manager: req[0x555b33c99b10, :1.32/nmcli-connect/0]: agent registered
  11. 8月 09 11:33:23 91centos91 NetworkManager[707]: <info> [1628480003.3997] audit: op="connection-activate" uuid="60f11468-542e-46f1-9119-018cb051d88f" name="enp5s5" result="fail" reason="No suitable device found for this connection (devic
  12. 8 09 11:33:23 91centos91 network[882]: 正在打开接口 enp5s5 错误:连接激活失败:No suitable device found for this connection (device enp5s4 not available because profile is not compatible with device (mismatching interface name)).
  13. 8 09 11:33:23 91centos91 network[882]: [失败]
  14. 8 09 11:33:23 91centos91 systemd[1]: network.service: control process exited, code=exited status=1
  15. 8 09 11:33:23 91centos91 systemd[1]: Failed to start LSB: Bring up/down networking.
  16. 8 09 11:33:23 91centos91 systemd[1]: Unit network.service entered failed state.
  17. 8 09 11:33:23 91centos91 systemd[1]: network.service failed.

3.DNS配置在 /etc/resolv.conf 路径下,公司这里是要把公司的两个DNS地址都加上,才能在远程机器访问到这台服务器

4.如果重启后也不能使网络生效可以试试以下操作

systemctl stop NetworkManager
systemctl disable NetworkManager
systemctl enable NetworkManager

route -n 查看路由
IP route flush dev 网卡名 清空路由
再重启网络 service network restart

重新启动网络管理器来生效。