VmWare虚拟机和主机配置为同一网段IP

参考博客:将虚拟机IP与主机IP设置在同一网段的方法 - 天懿 - 博客园 (cnblogs.com)

主机地址

主机通过WiFi连接,地址信息为:

image-20220417140341385

虚拟机配置

选择编辑-->虚拟网络编辑器-->更改设置:

image-20220417140638982

选择桥接模式,我这里用的是WiFi,如果是网口,根据自己情况选择。

image-20220417140953811

虚拟机网络适配器选择桥接模式。

image-20220417141846835

Linux下配置IP和网关

虚拟机配置好之后,启动虚拟机,然后配置IP和网关:

可参考我的另一篇博客:Centos7无法ping通内网、外网 - zhengcixi - 博客园 (cnblogs.com)

我使用的是Centos7,配置如下:

$ vim /etc/sysconfig/network-scripts/ifcfg-ens33

image-20220417142647314

重启网卡:

$ service network restart
Restarting network (via systemctl):                        [  OK  ]

测试

主机Ping虚拟机:

C:\Users\grace>ping 192.168.1.10

正在 Ping 192.168.1.10 具有 32 字节的数据:
来自 192.168.1.10 的回复: 字节=32 时间<1ms TTL=64
来自 192.168.1.10 的回复: 字节=32 时间=1ms TTL=64
来自 192.168.1.10 的回复: 字节=32 时间=1ms TTL=64
来自 192.168.1.10 的回复: 字节=32 时间=1ms TTL=64

192.168.1.10 的 Ping 统计信息:
    数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失),
往返行程的估计时间(以毫秒为单位):
    最短 = 0ms,最长 = 1ms,平均 = 0ms

虚拟机Ping网关:

$ ping 192.168.1.1
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=3.76 ms
64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=4.18 ms

虚拟机Ping百度:

$ ping www.baidu.com
PING www.a.shifen.com (220.181.38.149) 56(84) bytes of data.
64 bytes from 220.181.38.149 (220.181.38.149): icmp_seq=1 ttl=50 time=44.9 ms
64 bytes from 220.181.38.149 (220.181.38.149): icmp_seq=2 ttl=50 time=45.7 ms
posted @ 2022-04-17 14:34  zhengcixi  阅读(5936)  评论(0编辑  收藏  举报
回到顶部