centos7 ping 域名不通(yum无法下载)

具体设置

1.首先设置成虚拟机与宿主机网络连接模式为NAT模式连接 
这里写图片描述 
2.修改虚拟机的网络与宿主机的内网段在同一网段,(在同一个局域网),这一点非常重要,不然不能通过宿主机的ssh来连接centos 
VMware中: 编辑->虚拟网络编辑器 
选中虚拟机所使用的网卡进行NAT设置: 
这里写图片描述 
从上图中可以发现宿主机的子网ip为:192.168.1.0,所以我我们新增的网段只能为: 
192.168.1.x 要保证和宿主机同一个网段,然后设置两个映射入栈端口为22(ssh的登录端口号) 
这里写图片描述

验证设置

1.验证centos的网段是否是跟宿主机是否属于同一网段:192.168.1.x(博主宿主机局域网段) 
ssh登录虚拟机,成功登录,查看ip,可知跟宿主机在同一网段

[root@localhost ~]# ifconfig 
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.128  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::8133:d98a:f7e8:c2b1  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:a9:4d:e4  txqueuelen 1000  (Ethernet)
        RX packets 224  bytes 19916 (19.4 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 153  bytes 18599 (18.1 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 1  (Local Loopback)
        RX packets 72  bytes 6252 (6.1 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 72  bytes 6252 (6.1 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18

2.验证centos是否可以上网:能ping通,上网正常.

[root@localhost ~]# 
[root@localhost ~]# ping www.baidu.com
PING www.a.shifen.com (61.135.169.121) 56(84) bytes of data.
64 bytes from 61.135.169.121 (61.135.169.121): icmp_seq=1 ttl=128 time=6.41 ms
64 bytes from 61.135.169.121 (61.135.169.121): icmp_seq=2 ttl=128 time=6.57 ms
64 bytes from 61.135.169.121 (61.135.169.121): icmp_seq=3 ttl=128 time=8.02 ms

猜你喜欢

转载自blog.csdn.net/qq_35193093/article/details/81037065
今日推荐