I have 2 VMs (A
and B
) running locally (on host H
) with VirtualBox and I would like to be able to:
- ping
A
fromB
via an internal IP - ping
B
fromA
via an internal IP - ping 8.8.8.8 from
A
- ping 8.8.8.8 from
B
- access
A:22
fromH
- access
B:22
fromH
I'm currently using the NAT network setting on A
and B
, so I'm able to satisfy all requirements above apart 1 and 2.
I've tried changing this to internal network which satisfied only 1 and 2.
I've also used bridged networking which solved all those points but the problem is that A
and B
where now "exposed" in the local LAN by using 192.168.0.X type of addresses, which doesn't satisfy the "internal IP" requirement of 1 and 2.
What network configuration should I do on those 2 VMs to achieve this?
Best Answer
I solved it by adding 2 adapters on each VM. One for
NAT
and one forHost-only Adapter Network
.On the
NAT
I configured port forwards from2201
to22
etc. And when the VMs booted I had to configure their internal static IPs. They VMs are ubuntu so I had to edit/etc/network/interfaces
and add:and on the other VM:
After a
shutdown -r now
or aifup eth1
, the two VMs could ping each other via their internal IPs10.0.0.101
and10.0.0.102
.