13.虚拟机与主机通信:桥接模式与仅主机模式
2018-03-16 本文已影响0人
扶桑啊啊
之前我使用NAT模式设置了虚拟机的网络连接。最近了解了其他两种连接方式,桥接模式和HOST-ONLY模式。
桥接模式使用vmnet0网卡连接,NAT使用vmnet8连接,这两种模式不能与局域网内其他的主机进行通信;host-only使用vmnet1连接,能够与局域网内其他的主机进行通信。

一、桥接模式
1.在虚拟机的设置里将网络适配器改为桥接模式。

2.查看本机的IP地址(开始菜单-cmd-ipconfig)(必须保证虚拟机的IP和真实机IP在同一个网段)

3.将虚拟机的IP地址改为和主机地址同一个网段内的地址。

4.在主机ping一下虚拟机的地址看能不能通

5.如果ping不通的话,可能是桥接模式下自动选择网卡选择的错了,在虚拟机下手动选择本地网卡。

二、HOST-ONLY模式
虚拟机host-only使用vm1假网卡与主机之间进行通信,相当于是一台真正的计算机,能与局域网内其他的主机进行通信,缺点是占用了一个IP地址。
使用host-only方法:必须保证虚拟机的IP和真实机IP在同一个网段(如果不是,需要进行修改)
1.将网络适配器设置为仅主机模式(HOST-ONLY)

2.在本机查看VMnet1的IP地址

3.在虚拟机内将IP地址设为和VMnet1查到的IP地址同一个网段

4.在本机ping通刚刚设置的虚拟机地址。
