服务热线
135-6963-3175
网络查看
[root@localhost ~]# ifconfig br-6b7c1ae0fdb4: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500 inet 172.18.0.1 netmask 255.255.0.0 broadcast 172.18.255.255 ether 02:42:62:a9:89:1c txqueuelen 0 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 docker0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500 inet 172.17.0.1 netmask 255.255.0.0 broadcast 172.17.255.255 ether 02:42:3e:05:19:8c txqueuelen 0 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.1.50 netmask 255.255.255.0 broadcast 192.168.1.255 inet6 fe80::2675:8182:5ccc:d87e prefixlen 64 scopeid 0x20<link> ether 00:0c:29:24:08:87 txqueuelen 1000 (Ethernet) RX packets 174 bytes 18450 (18.0 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 149 bytes 16677 (16.2 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10<host> loop txqueuelen 1000 (Local Loopback) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
网卡名称ens33 lo docker0 br-6b7clae0fdb4
我们查看一下ens33的配置网络:
[root@localhost ~]# ls /etc/sysconfig/network-scripts/ ifcfg-eno16777736 ifdown-ppp ifup-ib ifup-Team ifcfg-lo ifdown-routes ifup-ippp ifup-TeamPort ifdown ifdown-sit ifup-ipv6 ifup-tunnel ifdown-bnep ifdown-Team ifup-isdn ifup-wireless ifdown-eth ifdown-TeamPort ifup-plip init.ipv6-global ifdown-ib ifdown-tunnel ifup-plusb network-functions ifdown-ippp ifup ifup-post network-functions-ipv6 ifdown-ipv6 ifup-aliases ifup-ppp ifdown-isdn ifup-bnep ifup-routes ifdown-post ifup-eth ifup-sit
发现没有找到ifcfg-ens33,我们新建或者把ifcfg-eno16777736改为ifcfg-ens33
[root@localhost network-scripts]# cp ifcfg-eno16777736.bak ifcfg-ens33 [root@localhost network-scripts]# ls ifcfg-eno16777736.bak ifdown-post ifup-eth ifup-sit ifcfg-ens33 ifdown-ppp ifup-ib ifup-Team ifcfg-lo ifdown-routes ifup-ippp ifup-TeamPort ifdown ifdown-sit ifup-ipv6 ifup-tunnel ifdown-bnep ifdown-Team ifup-isdn ifup-wireless ifdown-eth ifdown-TeamPort ifup-plip init.ipv6-global ifdown-ib ifdown-tunnel ifup-plusb network-functions ifdown-ippp ifup ifup-post network-functions-ipv6 ifdown-ipv6 ifup-aliases ifup-ppp ifdown-isdn ifup-bnep ifup-routes
查看一下ifcfg-ens33文件内容,并修改:
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 #改为ens33 NAME=ens33 UUID=a4bd030d-af36-475f-8894-57a33d468162 #改为ens33 DEVICE=ens33 ONBOOT=yes #ip地址 IPADDR="192.168.1.102" NETMASK="255.255.255.0" #网关 GATEWAY="192.168.1.1" DNS1="114.114.114.114"
esc wq保存
然后
[root@localhost ~]# service network restart
Restarting network (via systemctl): [ 确定 ]
[root@localhost ~]#
常见错误:
Job for network.service failed because the control process exited with error code问题
因为可能是克隆的,所以需要重新修改静态IP
可能有以下原因:
1.网卡名称不一致
2.mac地址有问题
ifconfig查看网卡名称
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.1.50 netmask 255.255.255.0 broadcast 192.168.1.255 inet6 fe80::2675:8182:5ccc:d87e prefixlen 64 scopeid 0x20<link> ether 00:0c:29:24:08:87 txqueuelen 1000 (Ethernet) RX packets 174 bytes 18450 (18.0 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 149 bytes 16677 (16.2 KiB)
网卡名称为ens33
修改下面文件,xxx正常应该为ens33,如果不对请修改
vim /etc/sysconfig/network-scripts/ifcfg-xxx
IPADDR=静态IP地址 GATEWAY=默认网关 NETMASK=255.255.255.0 DNS1=114.114.114.114 #网卡名称 NAME=ens33 UUID=a4bd030d-af36-475f-8894-57a33d468162 #网卡设备名称改为ens33 DEVICE=ens33
保存之后执行
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.
这时候就纠结了,跑去原来的系统中查看源码看是不是手误改到了哪一项,结果发现原来的系统也不行了, 使用 ifconfig查看了一下
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10<host> loop txqueuelen 1 (Local Loopback) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
少了一项网卡的,尝试着重启了系统,再测试一下,也是不行.跑去翻了网络上的大神门都是怎么解决了,尝试了数种方法,终于两个系统都解决了
在 /etc/sysconfig/network-scripts目录下删除掉别的ifcfg-xxx(只保留一个你网卡同名的文档)
再把NetworkManager停用
systemctl stop NetworkManager systemctl disable NetworkManager
使用 ip addr 查看 mac地址,把mac地址添加进 ifcfg-xxx 的HWADDR中(如果没有就再新添加一项)
HWADDR=xx:xx:xx:xx:xx:xx
:wq 保存之后再执行 systemctl restart network 就可以解决了