VirtualBox的网络设置(6种方式)

VirtualBox 能够为每个虚拟机分配8个网卡。每个网卡的链接方式能够选为下列之一:windows

  • Not attached
  • Network Address Translation (NAT)
  • Bridged networking
  • Host-only networking
  • Internal networking
  • Generic networking

去掉第一个和最后一个,咱们关心的只剩下4个:网络

(如下假定host在192.168.1.*网段中)tcp

Network Address Translation (NAT)

Hostoop

192.168.1.3spa

Guest1.net

10.0.2.15命令行

Guest2server

10.0.2.15blog

...接口

10.0.2.15

NAT是在虚拟机中访问外部网络的最简单的方式,是VirtualBox默认的网络模式。一般不须要对host和guest进行任何设置。

但因为虚拟机链接到的是VirtualBox内部的私有网络,使得虚拟机对其余虚拟机、对host以及网络上的其余计算机都是不可见的。为了使其某些端口对外部可见,须要使用 port forwarding。

经过VirtualBox界面或命令行,对名为windowsxp的虚拟机的nat网卡设置一个转发规则Rule1

VBoxManage modifyvm "windowsxp" --natpf1 "Rule1,tcp,,2222,,22"

格式:

--natpf<1-N> [<name>],tcp|udp,[<hostip>],<hostport>,[<guestip>], <guestport>

Bridged networking

它能够知足虚拟机中更高级的网络需求,好比运行servers等。它经过host的网卡,直接连入到host网络中。所以,虚拟机能被分配到一个中独立的IP,全部网络功能彻底和在网络中的真实机器同样。

Host

192.168.1.3

Guest1

192.168.1.4

Guest2

192.168.1.5

...

192.168.1.*

Internal networking

用来建立虚拟机间的网络,对host以及外部的计算机不可见。

Host

192.168.1.3

Guest1

169.254.75.244

Guest2

169.254.75.245

...

169.254.*.*

Host-only networking

Host

192.168.1.3

192.168.56.1

Guest1

192.168.56.101

Guest2

192.168.56.102

...

192.168.56.*

Host和若干个虚拟机之间的网络。Host中自动增长一个有点相似于local loopback接口,和Guest位于同一网段。

与外界的网络绝缘。不能访问外界网络,也不能被外部计算机访问。

其余

因为每一个虚拟机均可以设置8个网卡,每一个网卡能够选不一样的模式,故而能够有各类组合,从而实现各类效果。

http://blog.csdn.net/dbzhang800/article/details/6993261

相关文章
相关标签/搜索