VMware虚拟机与主机联通及配置上网

2023-02-14,,,,

vmware版本:10.0.0 build-1295980,安装redhat enterprise linux 5.8

一、物理机与虚拟机联通,但不联网

1、虚拟网络VMnet1设置:

此时,物理主机会自动添加一块虚拟的网卡VMnet1:

2、修改相应的虚拟网卡VMnet1的属性(网关与虚拟机里所安装系统的网关一致,IP设为同一网段)

3、虚拟机设置---->网络连接,修改如下:

 4、测试连接:

物理主机windows: ping VMnet1的IP通。ping 192.168.1.2

虚拟机系统linux: ping VMnet1的IP通。ping 192.168.1.2

物理主机windows和虚拟机linux 两者互ping也能联通。

这个方法是在主机上虚拟出一块网卡VMnet1,物理机与vmware通过这个虚拟网卡进行通信。

linux系统IP配置如下:

[root@rhel201 firefox]# cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
192.168.1.201 rhel201.com rhel201
[root@rhel201 firefox]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
# Intel Corporation 82545EM Gigabit Ethernet Controller (Copper)
DEVICE=eth0
BOOTPROTO=static
DHCPCLASS=
HWADDR=:0C::C5::E2
ONBOOT=yes
IPADDR=192.168.1.201
NETMASK=255.255.255.0
GATEWAY=192.168.1.1

二、配置linux系统能上网

使用桥接的方式使用虚拟机连接到物理主机的网络适配器(使用桥接方式时,虚拟网卡VM将不需要,会被自动卸载,一般配置Vmware里安装的操作系统与物理主机通信时使用该方式,这样虚拟机也能上网)如下,我的连接到无线网卡。

2、配置linux系统DNS,修改如下文件:

[root@rhel201 firefox]# cat /etc/resolv.conf
#search localdomain
nameserver 222.172.200.68
nameserver 61.166.150.123

3、测试上网连接正常

[root@rhel201 firefox]# ping www.baidu.com
PING www.a.shifen.com (180.97.33.107) () bytes of data.
bytes from 180.97.33.107: icmp_seq= ttl= time= ms
bytes from 180.97.33.107: icmp_seq= ttl= time=76.6 ms
bytes from 180.97.33.107: icmp_seq= ttl= time= ms --- www.a.shifen.com ping statistics ---
packets transmitted, received, % packet loss, time 7462ms
rtt min/avg/max/mdev = 76.610/162.193/267.104/78.961 ms
[root@rhel201 firefox]# ping www.taobao.com
PING www.gslb.taobao.com.danuoyi.tbcache.com (116.55.241.241) () bytes of data.
bytes from 241.241.55.116.broad.km.yn.dynamic.163data.com.cn (116.55.241.241): icmp_seq= ttl= time= ms

 三、vmware server版本的虚拟机与主机通信

vi /etc/sysconfig/network

加入GATEWAY=192.168.1.1

测试虚拟和主机互ping联通。

VMware虚拟机与主机联通及配置上网的相关教程结束。

《VMware虚拟机与主机联通及配置上网.doc》

下载本文的Word格式文档,以方便收藏与打印。