1.网络不正常原因
修改网络配置后发现不能上网了,执行ifconfig看到ens33已经没有IP地址,如下
[sandwich@centos-elk ~]$ ifconfig
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:fb:27:2d:97 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
ether 00:0c:29:3f:0c:ec txqueuelen 1000 (Ethernet)
RX packets 1 bytes 243 (243.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 60 bytes 10088 (9.8 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 64 bytes 5184 (5.0 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 64 bytes 5184 (5.0 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
virbr0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255
ether 52:54:00:d1:3a:4c txqueuelen 1000 (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
2.查看失败原因
[sandwich@centos-elk network-scripts]$ sudo ifup ens33
/etc/sysconfig/network-scripts/ifcfg-ens33: line 16: IPADDR-192.168.32.3: command not found
/etc/sysconfig/network-scripts/ifcfg-ens33: line 16: IPADDR-192.168.32.3: command not found
/etc/sysconfig/network-scripts/ifcfg-ens33: line 16: IPADDR-192.168.32.3: command not found
/etc/sysconfig/network-scripts/ifcfg-ens33: line 16: IPADDR-192.168.32.3: command not found
./ifcfg-ens33: line 16: IPADDR-192.168.32.3: command not found
原来是IPADDR地址配置的“=”写成“-”了
3.修改回来后重启网络
[sandwich@centos-elk network-scripts]$ service network restart
Restarting network (via systemctl): [ OK ]
4.确认ip地址正常
[sandwich@centos-elk network-scripts]$ ping www.baidu.com
PING www.a.shifen.com (163.177.151.109) 56(84) bytes of data.
64 bytes from 163.177.151.109 (163.177.151.109): icmp_seq=1 ttl=128 time=7.88 ms
64 bytes from 163.177.151.109 (163.177.151.109): icmp_seq=2 ttl=128 time=7.61 ms
64 bytes from 163.177.151.109 (163.177.151.109): icmp_seq=4 ttl=128 time=6.48 ms
64 bytes from 163.177.151.109 (163.177.151.109): icmp_seq=5 ttl=128 time=7.05 ms