I am running two VM instances of RHEL/CentOS on my VirtualBox instance running on host Windows 7. The problem is when I am executing VBoxManage list vms -l | more
and then sunsequently VBoxManage guestproperty get <uuid> "/VirtualBox/GuestInfo/Net/0/V4/IP"
, I can see the same IP for both the VMs. I have set the internal networking intnet
for both the VMs using Networks –> Adapter 2 –> PCnet-FAST III (Internal Network, 'intnet') and my understanding was that eth0 may have been the private network interface for the VMs. But both their IP is showing as 10.0.2.15. Is there a way I can access distinct IPs in the private VM network for the two VMs?
NOTE: I can also access only a single VM instance when accessing through Putty SSH client. And it is connecting to the proxy 127.0.0.1:2222 always. Thus I am not being able to distinguish between the VMs. I need separate instance accesses to run server and client codes on separate instances in a client-server architecture. See my other thread How to configure putty to ssh to multiple vm using same host which explains the problem in detail.
I am attaching the VBoxManage command line outputs as executed on the host. I am running 1.3_2 and 1.3_3 sandboxes but both have same IP as shown below in bold:
C:\Program Files\Oracle\VirtualBox>VBoxManage list vms
"Hortonworks Sandbox 1.3" {4914b5c7-1395-47f5-80ef-8fbec8cadbd4}
"Hortonworks Sandbox 1.3_1" {f103f5d2-f949-4d67-a81e-c63ddc5335dc}
"Hortonworks Sandbox 1.3_2" {fc2b9f50-bf4a-4a5d-8189-22d62c7e1d67}
"Hortonworks Sandbox 1.3_3" {5976fff1-7a0d-4eca-bedf-7756f7076dbd}
C:\Program Files\Oracle\VirtualBox>VBoxManage guestproperty get fc2b9f50-bf4a-4a
5d-8189-22d62c7e1d67 "/VirtualBox/GuestInfo/Net/0/V4/IP"
**Value: 10.0.2.15**
C:\Program Files\Oracle\VirtualBox>VBoxManage guestproperty get 5976fff1-7a0d-4e
ca-bedf-7756f7076dbd "/VirtualBox/GuestInfo/Net/0/V4/IP"
**Value: 10.0.2.15**
On the VM sandbox 1.3_2, I ran the below command to get the local IP for eth0 as below:
[hue@sandbox ~]$ arp -an
? (10.0.2.2) at 52:54:00:12:35:02 [ether] on eth0
[hue@sandbox ~]$ route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
10.0.2.0 * 255.255.255.0 U 0 0 0 eth0
link-local * 255.255.0.0 U 1002 0 0 eth0
default 10.0.2.2 0.0.0.0 UG 0 0 0 eth0
Any ideas how can I find the distinct IPs for the different sandboxes?
I see a similar thread how-to-do-networking-between-virtual-machines-in-virtualbox? where it is being said to use the dhcpserver for IP resolution of the guest VMs. But it asks for --ip
NOTE: I tried to run the VBoxManage dhcpserver but it asks for --ip
option and --netmask
which I have provided as below with the following output:
C:\Program Files\Oracle\VirtualBox>VBoxManage dhcpserver add --netname intnet --
netmask 10.0.2.*
Oracle VM VirtualBox Command Line Management Interface Version 4.3.0
(C) 2005-2013 Oracle Corporation
All rights reserved.
Usage:
VBoxManage dhcpserver add|modify --netname <network_name> |
--ifname <hostonly_if_name>
[--ip <ip_address>
--netmask <network_mask>
--lowerip <lower_ip>
--upperip <upper_ip>]
[--enable | --disable]
VBoxManage dhcpserver remove --netname <network_name> |
--ifname <hostonly_if_name>
Syntax error: You need to specify --ip option
While trying to enable the dhcpserver, it already exists:
C:\Program Files\Oracle\VirtualBox>VBoxManage dhcpserver add --netname intnet --
ip 10.0.2.15 --netmask 255.255.255.0 --lowerip 10.0.2.101 --upperip 10.0.2.254 -
-enable
VBoxManage.exe: error: DHCP server already exists
The output for route -n
and sudo ss -lntp
are as follows: (as requested by MariusMatiae)
[hue@sandbox ~]$ route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
10.0.2.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
192.168.56.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 eth0
0.0.0.0 10.0.2.2 0.0.0.0 UG 0 0 0 eth0
[hue@sandbox ~]$ sudo ss -lntp
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 10 *:8651 *:* users:(("gmetad",1046,0))
LISTEN 0 128 *:50060 *:* users:(("java",2797,86))
LISTEN 0 10 *:8652 *:* users:(("gmetad",1046,1))
LISTEN 0 128 10.0.2.15:50030 *:* users:(("java",2834,84))
LISTEN 0 128 127.0.0.1:34927 *:* users:(("java",2797,70))
LISTEN 0 50 *:10000 *:* users:(("java",1690,130))
LISTEN 0 128 :::80 :::* users:(("httpd",1282,4),("httpd",1414,4),("httpd",1415,4),("httpd",1416,4),("htt pd",1417,4),("httpd",1418,4),("httpd",1419,4),("httpd",1420,4),("httpd",1421,4))
LISTEN 0 128 ::ffff:10.0.2.15:60020 :::* users:(("java",3513,121))
LISTEN 0 128 10.0.2.15:8020 *:* users:(("java",1886,76))
LISTEN 0 128 10.0.2.15:50070 *:* users:(("java",1886,99))
LISTEN 0 128 :::22 :::* users:(("sshd",1191,4))
LISTEN 0 128 *:22 *:* users:(("sshd",1191,3))
LISTEN 0 100 :::11000 :::* users:(("java",2237,35))
LISTEN 0 128 :::5432 :::* users:(("postmaster",1550,4))
LISTEN 0 128 *:5432 *:* users:(("postmaster",1550,3))
LISTEN 0 128 *:8888 *:* users:(("python",1064,5),("python",5540,5))
LISTEN 0 1 ::ffff:127.0.0.1:11001 :::* users:(("java",2237,39))
LISTEN 0 100 127.0.0.1:25 *:* users:(("master",1272,12))
LISTEN 0 50 *:50010 *:* users:(("java",1884,75))
LISTEN 0 128 *:50075 *:* users:(("java",1884,76))
LISTEN 0 50 *:9083 *:* users:(("java",1797,125))
LISTEN 0 128 10.0.2.15:50300 *:* users:(("java",2834,74))
LISTEN 0 50 *:50111 *:* users:(("java",3142,261))
LISTEN 0 50 *:8000 *:* users:(("python2.6",3770,3),("python2.6",3843,3),("python2.6",3843,22))
LISTEN 0 50 *:8002 *:* users:(("java",3772,136))
LISTEN 0 50 :::2181 :::* users:(("java",2197,52))
LISTEN 0 128 10.0.2.15:51111 *:* users:(("java",2820,74))
LISTEN 0 50 :::48231 :::* users:(("java",2197,43))
LISTEN 0 128 127.0.0.1:199 *:* users:(("snmpd",1179,8))
LISTEN 0 50 *:9290 *:* users:(("java",2834,88))
LISTEN 0 128 *:8010 *:* users:(("java",1884,81))
LISTEN 0 128 10.0.2.15:50090 *:* users:(("java",1888,76))
LISTEN 0 50 *:3306 *:* users:(("mysqld",1460,10))
Best Answer
You have two possibilities:
set up a Host-only network. This requires the following steps:
a) File -> Preferences -> Network -> Host-only networks.
b) Add one by clicking on the
Plus
sign;c) Hit the screwdriver -> DHCP server. Check
Enable DHCP sever
d) fill in the mask as you like. Reasonable values are: Server Address 192.168.56.254 Server mask 255.255.255.0 Lower Adrress Bound 192.168.56.100 Upper Address Bound 192.168.56.200
Now configure your VMs to have at least one adapter on the Host-only network.
Start you VMs, and now your host has IP 192.168.56.1, and the various VMs are located at 192.168.56.100, 192.168.56.101,... You can now ping and sssh and vnc from one machne to the others.
EDIT:
In view of your routing table, solution 2 will work if you give these commands on both VMs: