NAT and Internal Network setup not allowing interconnection between VMs

Discussions related to using VirtualBox on Linux hosts.
Post Reply
macourtney7
Posts: 2
Joined: 1. Mar 2017, 14:58

NAT and Internal Network setup not allowing interconnection between VMs

Post by macourtney7 »

I'm trying to setup a cluster of Ubuntu 16.04 server VMs on a 16.04 desktop host.

I would like to be able to ssh into the VMs individually and also support inter VM networking.

Ideally using a dual networking interface so that VM->VM traffic is private.

My configuration is as follows:

Code: Select all

NAT with port forwarding rules to allow host->vm ssh

Internal Networking using default intnet
I've created a DHCP server:

Code: Select all

vboxmanage dhcpserver add --netname intnet --ip 10.10.10.1 --netmask 255.255.255.0 --lowerip 10.10.10.2 --upperip 10.10.10.12 --enable
Currently, the NAT part of the networking is working as expected, I can ssh into the machines.

However, all of the VMs ifconfig is exactly the same; no real IP is issued:

Code: Select all

enp0s3    Link encap:Ethernet  HWaddr 08:00:27:68:71:2a  
          inet addr:10.0.2.15  Bcast:10.0.2.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:59 errors:0 dropped:0 overruns:0 frame:0
          TX packets:46 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:7081 (7.0 KB)  TX bytes:7053 (7.0 KB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:160 errors:0 dropped:0 overruns:0 frame:0
          TX packets:160 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1 
          RX bytes:11840 (11.8 KB)  TX bytes:11840 (11.8 KB)
The VMs are clones of each other so I've regenerated MAC addresses.

I also tried removing some of the network settings files and rebooting which didn't change anything:

Code: Select all

sudo rm -rf /etc/udev/rules.d/70-persistent-net.rules
What am I doing wrong in getting this configured?

Any help is much appreciated!
socratis
Site Moderator
Posts: 27329
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: NAT and Internal Network setup not allowing interconnection between VMs

Post by socratis »

[pre]+-----------+-------------+-------------+----------------+----------------+
| | VM <-> Host | VM1 <-> VM2 | VM -> Internet | VM <- Internet |
+-----------+-------------+-------------+----------------+----------------+
| HostOnly | Yes | Yes | No | No |
| Internal | No | Yes | No | No |
| Bridged | Yes | Yes | Yes | Yes |
| NAT | No | No | Yes | Port forward |
| NATNet | No | Yes | Yes | No |
+-----------+-------------+-------------+----------------+----------------+[/pre]

Bridged will allow your guest to appear as just another PC on your host's network. The host, all the other network PCs, the internet and the guest can all communicate. The guest would default to getting an IP address from your host network's router. The host needs to be connected to an active network to allow guests to use Bridged. And Bridged is not always compatible with Wi-Fi.

Internal makes a private network just for your guests. There is no host communication or internet. There is no DCHP server on an internal network by default, though you can put one on in Virtualbox. Otherwise configure static IP address for the guests within the guest OS's. Or you can make a router guest using a router OS like pfSense. You can make more than one internal network by naming the new networks differently.

Host-Only is a special form of internal network that also includes the host, via a virtual Host-Only network adapter made on your host, defaulting to IP address 192.168.56.1, and there is a default DHCP server handing out IP addresses to the guests starting at 192.168.56.101. You can change the IP address range or make multiple host-only networks in Virtualbox's Network settings in the main GUI. There is no internet in Host-Only.

Virtualbox has two kinds of NAT: regular NAT and a NAT network service. Regular NAT ("NAT" in the dropdown) connects each guest to the host's network connection and internet via an independent channel. The host and any other guests cannot connect to the NAT-connected guest, although ports can be opened, just like NAT in a router. (The NAT guest can, however, see any services and shared folders on the host's network.)

The NAT network service ("NAT network" in the dropdown) is like a home router, NAT to the outside world and multiple "LAN" guest connections. All the guests connected to this "NAT network" can see and communicate with each other. Internet is accessible. Ports can be opened just like a real router. You need to make a new NAT network in the main Virtualbox window, File Menu, Preferences, Network. Then attach the guests using the name of the NAT network you made in Preferences.

You need the Internal mode.
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
macourtney7
Posts: 2
Joined: 1. Mar 2017, 14:58

Re: NAT and Internal Network setup not allowing interconnection between VMs

Post by macourtney7 »

I've added an Internal Network adaptor to each of the guests and created a DHCP server via vboxmanage but I'm not getting an IP issued. Each guest has the same virtual IP that comes as standard.

When I use a bridged adaptor (wired connection) as the only network interface I get no IP issued at all.

Code: Select all

lo        Link encap:Local Loopback 
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:480 errors:0 dropped:0 overruns:0 frame:0
          TX packets:480 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1
          RX bytes:35520 (35.5 KB)  TX bytes:35520 (35.5 KB)
socratis
Site Moderator
Posts: 27329
Joined: 22. Oct 2010, 11:03
Primary OS: Mac OS X other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Win(*>98), Linux*, OSX>10.5
Location: Greece

Re: NAT and Internal Network setup not allowing interconnection between VMs

Post by socratis »

macourtney7 wrote:and created a DHCP server via vboxmanage
Why, oh, why? Why don't you keep things simple? The simplest thing to do now is to do the following steps exactly:
  1. Delete ($HOME/.VirtualBox/VirtualBox.xml). That will reset your settings, including your registered VMs. Don't worry, they're still there, they are simply not registered.
  2. Start with VM1. Register/Add it to VirtualBoxManager. For Adapter1 in the network, attach it to Internal. Disable any other adapters.
  3. Continue with VM2. Register/Add it to VirtualBoxManager. For Adapter1 in the network, attach it to Internal. Disable any other adapters.
  4. Launch both VMs, make sure they communicate, make sure they have different IPs, ping each other.
  5. Continue with any (if at all) VMs.
NOTE: No step involved a DHCP server. Do NOT add one...
Do NOT send me Personal Messages (PMs) for troubleshooting, they are simply deleted.
Do NOT reply with the "QUOTE" button, please use the "POST REPLY", at the bottom of the form.
If you obfuscate any information requested, I will obfuscate my response. These are virtual UUIDs, not real ones.
Post Reply