对不起,基本的问题,但我不能找出这一个。 我想build立一个小型的Linux服务器networking进行testing。
所以我有一个主机服务器运行虚拟框与以下接口:
wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.0.4 netmask 255.255.255.0 broadcast 192.168.0.255 Then a guest vm with the following networking set up: eth0 Link encap:Ethernet HWaddr 08:00:27:EA:15:4F inet addr:192.168.0.2 Bcast:192.168.0.255 Mask:255.255.255.0 eth1 Link encap:Ethernet HWaddr 08:00:27:E3:E2:BC inet addr:172.16.0.1 Bcast:172.16.7.255 Mask:255.255.248.0
第二位客串嘉宾如下:
eth0 Link encap:Ethernet HWaddr 08:00:27:15:CA:14 inet addr:172.16.0.2 Bcast:172.16.7.255 Mask:255.255.248.0 inet6 addr: fe80::a00:27ff:fe15:ca14/64 Scope:Link
我希望能够从vm 2路由回主机服务器。 于是我创build了一条告诉vm 2的路由,通过vm 1发送192.169.0.0networking的stream量:
% route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 192.168.0.0 172.16.0.1 255.255.255.0 UG 0 0 0 eth0 172.16.0.0 0.0.0.0 255.255.248.0 U 0 0 0 eth0 169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 eth0
但是我无法从vm 2 ping到192.168.0.0networking.vm 1上的路由表如下:
% route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0 172.16.0.0 0.0.0.0 255.255.248.0 U 0 0 0 eth1 169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 eth0 169.254.0.0 0.0.0.0 255.255.0.0 U 1003 0 0 eth1 0.0.0.0 192.168.0.1 0.0.0.0 UG 0 0 0 eth0
主机服务器(正在运行虚拟机)的路由表为:
% route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 192.168.0.1 0.0.0.0 UG 0 0 0 wlan0 192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 wlan0
所以我想我的问题是,主机服务器不知道我的虚拟机的172.16.0.0/16networking,无法回复。
我怎样才能解决这个问题,我将不得不使用iptables和NATing?
我只用一个Windows主机和Linux Guest做过这个,但是原理应该是一样的。
检查以下链接,特别是在仅主机networking上
http://www.virtualbox.org/manual/ch06.html#networkingmodes
我不需要用这个方法编辑路由。
你可能想探索的另一条路线是使用Vagrant。 http://www.vagrantup.com/它非常适合testing不同的configuration并快速设置新的虚拟机。 祝你好运