CentOS7之VMware的NAT模式ping不通宿主机、ping不通外网
前提:宿主机:Windows10虚拟机:CentOS7VMware版本:VMware Workstation 16 ProNAT模式ping不通宿主机及外网1、确认NAT模式2、确认虚拟机模式,及子网IP、子网掩码、网关子网IP:192.168.111.0子网掩码:255.255.255.0# 网关要与子网IP在同一网段网关:192.168.111.23、进入CentOS7,修改3个文件vi /e
·
前提:
宿主机:Windows10
虚拟机:CentOS7
VMware版本:VMware Workstation 16 Pro
NAT模式ping不通宿主机及外网
1、确认NAT模式
2、确认虚拟机模式,及子网IP、子网掩码、网关
子网IP:192.168.111.0
子网掩码:255.255.255.0
# 网关要与子网IP在同一网段
网关:192.168.111.2
3、进入CentOS7,修改3个文件
vi /etc/sysconfig/network-scripts/ifcfg-ens33
TYPE="Ethernet"
PROXY_METHOD="none"
BROWSER_ONLY="no"
BOOTPROTO="static" # 修改为静态
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_FAILURE_FATAL="no"
IPV6_ADDR_GEN_MODE="stable-privacy"
NAME="ens33"
UUID="ea3b61ed-9232-4b69-b6c0-2f863969e750"
DEVICE="ens33"
ONBOOT="yes"
IPADDR="192.168.111.129" # 添加,要与上面的子网在同一网段内
NETMASK="255.255.255.0" # 添加,将上面的子网掩码复制下来
GETWAY="192.168.111.2" # 添加,将上面的网关复制下来
DNS1="192.168.111.2" # 修改,将上面的网关复制下来
vi /etc/sysconfig/network
# Created by anaconda
NETWORKING=yes
HOSTNAME=Taoge
GATEWAY=192.168.111.2
vi /etc/resolv.conf
# Generated by NetworkManager
nameserver 192.168.111.2
重启网络服务
service network restart
验证ok
[root@bogon ~]# ping www.baidu.com
PING www.a.shifen.com (220.181.38.150) 56(84) bytes of data.
64 bytes from 220.181.38.150 (220.181.38.150): icmp_seq=1 ttl=128 time=8.63 ms
64 bytes from 220.181.38.150 (220.181.38.150): icmp_seq=2 ttl=128 time=7.96 ms
64 bytes from 220.181.38.150 (220.181.38.150): icmp_seq=3 ttl=128 time=8.60 ms
^C
--- www.a.shifen.com ping statistics ---
5 packets transmitted, 4 received, 20% packet loss, time 4007ms
rtt min/avg/max/mdev = 7.961/9.781/13.928/2.409 ms
[root@bogon ~]# ping 192.168.10.160
PING 192.168.10.160 (192.168.10.160) 56(84) bytes of data.
64 bytes from 192.168.10.160: icmp_seq=1 ttl=128 time=0.942 ms
64 bytes from 192.168.10.160: icmp_seq=2 ttl=128 time=0.973 ms
64 bytes from 192.168.10.160: icmp_seq=3 ttl=128 time=1.43 ms
^C
--- 192.168.10.160 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2004ms
rtt min/avg/max/mdev = 0.942/1.116/1.434/0.226 ms
更多推荐
已为社区贡献2条内容
所有评论(0)