001、网络模式
002、 网卡配置文件(网关末位为1时)
[root@PC1 network-scripts]# pwd ## 当前路径 /etc/sysconfig/network-scripts [root@PC1 network-scripts]# grep -i gateway ifcfg-ens33 ## 提取网关信息 GATEWAY=192.168.87.1 [root@PC1 network-scripts]# systemctl restart network ## 重置网络服务 [root@PC1 network-scripts]# ping -c 3 www.baidu.com ## 测试网络连通信 ping: www.baidu.com: Name or service not known
003、网卡配置文件(网关末尾为2时)
[root@PC1 network-scripts]# pwd /etc/sysconfig/network-scripts [root@PC1 network-scripts]# sed '/GATEWAY/ s/.$/2/' ifcfg-ens33 -i ## 修改网卡配置文件 [root@PC1 network-scripts]# grep -i gateway ifcfg-ens33 ## 提取网卡信息 GATEWAY=192.168.87.2 [root@PC1 network-scripts]# systemctl restart network ## 重置网络服务 [root@PC1 network-scripts]# ping -c 3 www.baidu.com ## 测试网络连通性 PING www.a.shifen.com (39.156.66.18) 56(84) bytes of data. 64 bytes from 39.156.66.18 (39.156.66.18): icmp_seq=1 ttl=128 time=12.5 ms 64 bytes from 39.156.66.18 (39.156.66.18): icmp_seq=2 ttl=128 time=12.8 ms 64 bytes from 39.156.66.18 (39.156.66.18): icmp_seq=3 ttl=128 time=12.5 ms --- www.a.shifen.com ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 2003ms rtt min/avg/max/mdev = 12.567/12.651/12.809/0.171 ms
标签:网关,network,##,39.156,虚拟机,PC1,NAT,scripts,root From: https://www.cnblogs.com/liujiaxin2018/p/17062263.html