2016-04-06 48 views
0

主持人:窗戶8.1如何兩個虛擬框之間的溝通主機

guest1虛擬機(服務器運行):Ubuntu的14.04

guest2(Server2上運行):Ubuntu的14.04

我做了什麼

我在guest1中有端口8558,用於處理來自主機的請求,並且它的工作正常。現在我想請求guest1到在端口5672上運行的guest2服務器。爲此,我有向前端口5672 ST2。

問題

當我連接到guest2它失敗。 我不能在guest2中獲得請求。

如何解決此問題?

+0

同樣的問題我有.. !!我從我的主機窗口和我的虛擬框兩個客戶操作系統發送HttpRequest!在第一OS Web服務運行和第二個客戶運行另一臺服務器,但端口轉發問題!我的網絡服務器沒有找到另一臺服務器在第二位客人中運行!請給點意見吧! –

回答

0

我使用兩個Debian VM,我可以從另一個訪問一個VM,反之亦然。使用Ubuntu虛擬機應該沒有區別。這裏是我的設置:

VirtualBox的:5.0.24 r108355

主機:OS X 10.11.5

VM1:Debian的傑西

VM2:Debian的彈力

On the主機

1)創建NatNetwork:

VirtualBox -> Preferences -> Network -> NAT Networks -> Add new NAT Network 

2)創建一個唯一的主機網絡:

VirtualBox -> Preferences -> Network -> Host-only Networks -> Add host-only network 

3)在每個客人,添加一個納特網絡和一個主機僅適配器連接到您在主機上創建的相同接口。選擇半虛擬化網絡(virtio-net)作爲適配器類型。

在VM1(Debian的傑西)

4)修改/etc/network/interfaces這樣

source /etc/network/interfaces.d/* 

auto lo 
iface lo inet loopback 

allow-hotplug eth0 
iface eth0 inet dhcp 

allow-hotplug eth1 
iface eth1 inet dhcp 

在VM2(Debian的彈力)

5)修改/etc/network/interfaces這樣

source /etc/network/interfaces.d/* 

auto lo 
iface lo inet loopback 

allow-hotplug enp0s3 
iface enp0s3 inet dhcp 

allow-hotplug enp0s8 
iface enp0s8 inet dhcp 

請注意,在Debian中,網絡接口命名方案已更改。接口被命名爲enp0s*,不再有eth*

在此之後,一切都應該是可操作的。答案的其餘部分僅用於信息目的。

每位嘉賓將有兩個IP地址,一個用於主機通信,一個用於互聯網訪問。

在VM1(Debian的傑西)

eth0  Link encap:Ethernet HWaddr 08:00:27:09:e8:02 
      inet addr:192.168.56.101 Bcast:192.168.56.255 Mask:255.255.255.0 
      inet6 addr: fe80::a00:27ff:fe09:e802/64 Scope:Link 
      UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 
      RX packets:330 errors:0 dropped:0 overruns:0 frame:0 
      TX packets:168 errors:0 dropped:0 overruns:0 carrier:0 
      collisions:0 txqueuelen:1000 
      RX bytes:52722 (51.4 KiB) TX bytes:21827 (21.3 KiB) 

eth1  Link encap:Ethernet HWaddr 08:00:27:8a:dc:96 
      inet addr:10.0.2.4 Bcast:10.0.2.255 Mask:255.255.255.0 
      inet6 addr: fe80::a00:27ff:fe8a:dc96/64 Scope:Link 
      UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 
      RX packets:462 errors:0 dropped:0 overruns:0 frame:0 
      TX packets:421 errors:0 dropped:0 overruns:0 carrier:0 
      collisions:0 txqueuelen:1000 
      RX bytes:61578 (60.1 KiB) TX bytes:38012 (37.1 KiB) 

在VM2(Debian的彈力)

enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 
     inet 10.0.2.15 netmask 255.255.255.0 broadcast 10.0.2.255 
     inet6 fe80::a00:27ff:fedc:d009 prefixlen 64 scopeid 0x20<link> 
     ether 08:00:27:dc:d0:09 txqueuelen 1000 (Ethernet) 
     RX packets 75 bytes 19672 (19.2 KiB) 
     RX errors 0 dropped 0 overruns 0 frame 0 
     TX packets 81 bytes 10902 (10.6 KiB) 
     TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 

enp0s8: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 
     inet 192.168.56.102 netmask 255.255.255.0 broadcast 192.168.56.255 
     inet6 fe80::a00:27ff:fe4b:811e prefixlen 64 scopeid 0x20<link> 
     ether 08:00:27:4b:81:1e txqueuelen 1000 (Ethernet) 
     RX packets 329 bytes 39627 (38.6 KiB) 
     RX errors 0 dropped 0 overruns 0 frame 0 
     TX packets 231 bytes 30290 (29.5 KiB) 
     TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 

在VM1

Kernel IP routing table 

Destination  Gateway   Genmask   Flags Metric Ref Use Iface 
default   10.0.2.1  0.0.0.0   UG 0  0  0 eth1 
10.0.2.0  *    255.255.255.0 U  0  0  0 eth1 
link-local  *    255.255.0.0  U  1000 0  0 eth0 
192.168.56.0 *    255.255.255.0 U  0  0  0 eth0 
路由表0

VM2中的原理相同。

+0

如果你是在一個公司代理的背後,不要忘記它。 https://superuser.com/questions/78157/configure-virtualbox-to-connect-to-internet-through-proxy –