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

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=00:0C:29:C5:02: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) 56(84) bytes of data.
64 bytes from 180.97.33.107: icmp_seq=1 ttl=54 time=142 ms
64 bytes from 180.97.33.107: icmp_seq=3 ttl=54 time=76.6 ms
64 bytes from 180.97.33.107: icmp_seq=4 ttl=54 time=267 ms

--- www.a.shifen.com ping statistics ---
4 packets transmitted, 3 received, 25% 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) 56(84) bytes of data.
64 bytes from 241.241.55.116.broad.km.yn.dynamic.163data.com.cn (116.55.241.241): icmp_seq=1 ttl=48 time=242 ms

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

vi /etc/sysconfig/network

加入GATEWAY=192.168.1.1

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

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值