CentOS 7 docker 部署遇到内网通,外网不通 问题
[root@localhost ~]# systemctl status network
● network.service - LSB: Bring up/down networkingLoaded: loaded (/etc/rc.d/init.d/network; bad; vendor preset: disabled)Active: failed (Result: exit-code) since Tue 2024-09-03 14:21:22 CST; 4min 31s agoDocs: man:systemd-sysv-generator(8)Process: 2974 ExecStart=/etc/rc.d/init.d/network start (code=exited, status=1/FAILURE)Tasks: 0Memory: 152.0KSep 03 14:21:21 localhost.localdomain network[2974]: RTNETLINK answers: File exists
Sep 03 14:21:21 localhost.localdomain network[2974]: RTNETLINK answers: File exists
Sep 03 14:21:21 localhost.localdomain network[2974]: RTNETLINK answers: File exists
Sep 03 14:21:21 localhost.localdomain network[2974]: RTNETLINK answers: File exists
Sep 03 14:21:21 localhost.localdomain network[2974]: RTNETLINK answers: File exists
Sep 03 14:21:21 localhost.localdomain network[2974]: RTNETLINK answers: File exists
Sep 03 14:21:22 localhost.localdomain systemd[1]: network.service: control process exited, code=exited status=1
Sep 03 14:21:22 localhost.localdomain systemd[1]: Failed to start LSB: Bring up/down networking.
Sep 03 14:21:22 localhost.localdomain systemd[1]: Unit network.service entered failed state.
Sep 03 14:21:22 localhost.localdomain systemd[1]: network.service failed.
解决方法:
1、禁止开机启动
systemctl stop NetworkManager
2、禁止开机启动
systemctl disable NetworkManager
3、重启网卡
systemctl restart network
再次重启网卡,启动成功
分析原因:
重启网卡
systemctl restart network
如果重启/启动网卡失败,提示
Job for network.service failed because the control process exited with error code. See "systemctl status network.service" and "journalctl -xe" for details.
原文链接:linux网卡启动失败参考_linux重启网卡失败-CSDN博客
则使用 systemctl status network.service 命令查看错误详情。
[root@localhost ~]# systemctl status network
● network.service - LSB: Bring up/down networkingLoaded: loaded (/etc/rc.d/init.d/network; bad; vendor preset: disabled)Active: failed (Result: exit-code) since Tue 2024-09-03 14:21:22 CST; 4min 31s agoDocs: man:systemd-sysv-generator(8)Process: 2974 ExecStart=/etc/rc.d/init.d/network start (code=exited, status=1/FAILURE)Tasks: 0Memory: 152.0KSep 03 14:21:21 localhost.localdomain network[2974]: RTNETLINK answers: File exists
Sep 03 14:21:21 localhost.localdomain network[2974]: RTNETLINK answers: File exists
Sep 03 14:21:21 localhost.localdomain network[2974]: RTNETLINK answers: File exists
Sep 03 14:21:21 localhost.localdomain network[2974]: RTNETLINK answers: File exists
Sep 03 14:21:21 localhost.localdomain network[2974]: RTNETLINK answers: File exists
Sep 03 14:21:21 localhost.localdomain network[2974]: RTNETLINK answers: File exists
Sep 03 14:21:22 localhost.localdomain systemd[1]: network.service: control process exited, code=exited status=1
Sep 03 14:21:22 localhost.localdomain systemd[1]: Failed to start LSB: Bring up/down networking.
Sep 03 14:21:22 localhost.localdomain systemd[1]: Unit network.service entered failed state.
Sep 03 14:21:22 localhost.localdomain systemd[1]: network.service failed.
出现这种报错一般是和 NetworkManager 服务冲突导致的,直接关闭 NetworkManger 服务就好了,
1、禁止开机启动
systemctl stop NetworkManager
2、禁止开机启动
systemctl disable NetworkManager
3、重启网卡
systemctl restart network
如果还有问题的话,继续往下看
上述操作以后还是不行的话,可能是文件权限的问题,找到网卡信息(ip addr 指令查看自己的网络名称 ,本文的是enp2s0),所以如下:
sudo chmod 777 ./ifcfg-enp2s0
重启网卡
systemctl restart network
还不行的话,再添加mac id
查询 ip
ip addr
如下图红框标记的几位硬件macid
配置文件添加/修改Mac
vi /etc/sysconfig/network-scripts/ifcfg-eth0#添加修改Mac地址
HWADDR=00:e0:**:01:**:63
3)、重启网络
systemctl restart network#查看网络
systemctl status network