克隆CentOS7时出现的网络问题及解决方案(转)

2020/07/28 09:30
阅读数 865

1.克隆CentOS7 出现的网络问题

1.1. 现象:

[root@localhost ~]# systemctl startnetwork.service

Job for network.service failed because thecontrol process exited with error code. See "systemctl statusnetwork.service" and "journalctl -xe" for details.

[root@localhost ~]# systemctl statusnetwork.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 Fri 2017-09-22 16:54:29 CST;12s ago

Docs: man:systemd-sysv-generator(8)

Process: 2405 ExecStart=/etc/rc.d/init.d/network start (code=exited,status=1/FAILURE)

 

Sep 22 16:54:29 localhost.localdomainnetwork[2405]: RTNETLINK answers: File exists

Sep 22 16:54:29 localhost.localdomainnetwork[2405]: RTNETLINK answers: File exists

Sep 22 16:54:29 localhost.localdomainnetwork[2405]: RTNETLINK answers: File exists

Sep 22 16:54:29 localhost.localdomainnetwork[2405]: RTNETLINK answers: File exists

Sep 22 16:54:29 localhost.localdomainnetwork[2405]: RTNETLINK answers: File exists

Sep 22 16:54:29 localhost.localdomainnetwork[2405]: RTNETLINK answers: File exists

Sep 22 16:54:29 localhost.localdomainsystemd[1]: network.service: control process exited, code=exited status=1

Sep 22 16:54:29 localhost.localdomainsystemd[1]: Failed to start LSB: Bring up/downnetworking.

Sep 22 16:54:29 localhost.localdomainsystemd[1]: Unit network.service entered failed state.

Sep 22 16:54:29 localhost.localdomainsystemd[1]: network.service failed.

1.2. 解决方案

1)利用 ip addr查看网卡配置

[root@localhost ~]#ip addr

1: lo: mtu 65536 qdisc noqueue stateUNKNOWN qlen 1

link/loopback00:00:00:00:00:00 brd 00:00:00:00:00:00

inet 127.0.0.1/8 scopehost lo

valid_lft foreverpreferred_lft forever

inet6 ::1/128 scope host

valid_lft foreverpreferred_lft forever

2: ens33: mtu 1500 qdisc pfifo_fast state UP qlen1000

link/ether 00:0c:29:2b:d9:95 brdff:ff:ff:ff:ff:ff

inet 192.168.58.140/24 brd192.168.58.255 scope global dynamic ens33

valid_lft 1310secpreferred_lft 1310sec

inet6fe80::38dd:47dd:657e:878f/64 scope link

valid_lft foreverpreferred_lft forever

3: virbr0: mtu 1500 qdiscnoqueue state DOWN qlen 1000

link/ether52:54:00:f6:93:a1 brd ff:ff:ff:ff:ff:ff

inet 192.168.122.1/24 brd192.168.122.255 scope global virbr0

valid_lft foreverpreferred_lft forever

4: virbr0-nic: mtu 1500 qdisc pfifo_fastmaster virbr0 state DOWN qlen 1000

link/ether 52:54:00:f6:93:a1 brdff:ff:ff:ff:ff:ff

红色字体部分 为网卡物理地址

2)修改配置

n vim /etc/sysconfig/network-scripts/ifcfg-eno16777736(文件名字根据实际环境选择)

UUID=ca287b1d-5142-4faa-a2e0-da94ac0c4070

 

 

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=ca287b1d-5142-4faa-a2e0-da94ac0c4070 删除此行

DEVICE=eno16777736

ONBOOT=yes

IPADDR=192.168.58.133

NETMASK=255.255.255.0

BROADCASE=192.168.58.255

DNS1=8.8.8.8

DNS2=114.114.114.114

HWADDR=00:0c:29:2b:d9:95 添加或修改物理地址为ip addr 查看的地址

 

n vim /etc/udev/rules.d/70-persistent-ipoib.rules

# ACTION=="add", SUBSYSTEM=="net",DRIVERS=="?*", ATTR{type}=="32", ATTR{address}=="?*00:0c:29:2b:d9:95",NAME="mlx4_ib3"

将其中的mac 修改为上部一样的mac地址

n mv /etc/sysconfig/network-scripts/ifcfg-eno16777736/etc/sysconfig/network-scripts/ifcfg-ens33(修改为ip addr 显示的名称)

n reboot 重启电脑问题解决

[root@localhost~]# systemctl status network.service

network.service - LSB: Bring up/downnetworking

Loaded: loaded (/etc/rc.d/init.d/network;bad; vendor preset: disabled)

Active: active (exited) since Fri 2017-09-2217:17:16 CST; 2min 6s ago

Docs: man:systemd-sysv-generator(8)

Process: 687ExecStart=/etc/rc.d/init.d/network start (code=exited, status=0/SUCCESS)

 

Sep 2217:17:16 localhost.localdomain systemd[1]: Starting LSB: Bring up/downnetworking...

Sep 2217:17:16 localhost.localdomain network[687]: Bringing up loopbackinterface: [ OK ]

Sep 2217:17:16 localhost.localdomain network[687]: Bringing up interface ens33: [OK ]

Sep22 17:17:16 localhost.localdomain systemd[1]: Started LSB: Bring up/downnetworking.

展开阅读全文
打赏
0
0 收藏
分享
加载中
更多评论
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部