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聯通。