How-to: VirtualBox Host-Only Network Mode (2021)
The VirtualBox Networking Primer in paperback and Kindle Ebook formats on Amazon as well as ebooks on Kobo and Apple Books.Let's look at the Host-Only Network mode in VirtualBox.
Under the Host-Only mode, virtual machines can communicate between each other and with the hosting system but not outside. Under Host-Only Networking the Host and the Guest virtual machines sit on a private network, which is useful where machines need access to one another, but nothing outside the Host-Only subnet. All virtual machines sitting on a Host-Only network will see each other.
The virtual network adapters of the virtual machines don’t have a gateway in their IP configuration because the Host-Only mode doesn’t allow connections to any devices outside the Host-Only network. With the Host connected to the internal network it can see the virtual machines and provide DHCP services. However, other external machines and networks cannot see Guests on this network, hence the name “Host-Only”.
Host-Only uses a dedicated network device to lease IP addresses, with VirtualBox providing a default called vboxnet0. You can also create your own Host-Only network devices as needed. Importantly, Host-Only adapters, both vboxnet0 and your own, do not enable your virtual machines with Internet access, as Host-Only does not have a default gateway.
The Host machine becomes the default VirtualBox router, with the IP address of 192.168.56.1 (you can change this). When virtual machines boot up with Host-only configured, this adapter assigns IP addresses to the virtual machines to create an internal LAN which cannot be seen by any other networks.
If your host has the IP address of 192.168.56.1, your first virtual machine will be given the IP address of 192.168.56.101.
Practice: Create and Connect a Host-Only Network
On the Host
To configure Host-Only networking you need a VirtualBox Host-Only Ethernet Adapter. VirtualBox comes with one as a default, vboxnet0, preconfigured.
In the VirtualBox Manager window, Select File, Preferences. Select Host Network Manager. This will list all the Host-Only networks available. There is one default, vboxnet0. Clicking on the Properties button will show you the edit dialog, opening on the Adapter tab first.
Host Only adapter settings
You can also edit the properties of the Host-Only adapter to set an IP address or configure DHCP.
If you need to create a new Host-Only network, you can hit the Create button.
The Adapter tab details the addressing for the selected network. The IPv4 address – the familiar xxx.xxx.xxx.xxx format – will have defaulted to 126.96.36.199 for the Host gateway. The Net Mask will be the usual 255.255.255.0. The IPv6 address will be initially blank and you will have to obtain the address to paste in here if you require IPv6 support in this network set up.
You may configure this manually. If you choose a different Host IP address, make sure it doesn’t already exist on your physical network.
Host-Only DHCP settings
Changing tabs by selecting DHCP allows you to enable the built-in DHCP server for this network which will dynamically allocate the IP addresses for all of the Guests connecting to it. On filling the checkbox for Enable Server, VirtualBox auto-completes all of the addressing for server, server mask and the limit of IP addresses within this subnet. If you have manually set the Host IP address, the DHCP settings will draw on this for the server and Guest range of IP addresses in this subnet.
In our case, the default network address of the Host-Only network is 192.168.56.0/24 and the IP address of the virtual network adapter on the Host machine is 192.168.56.1. You can edit these IP addresses manually in the Adapter tab. A DHCP server can be enabled or disabled by ticking the appropriate checkbox. In the DHCP Server tab, you can set the IP address of the DHCP server, net-mask and the range of IP addresses to be issued for DHCP clients.
On the Guest
From the Network Settings of the Virtual Machine you select Host-Only Adapter in the Attached to field and the name of the adapter that you created above.
In the Host-Only network configuration as illustrated:
- The IP address for the host is 192.168.56.1 (network mask 255.255.255.0)
- The virtual machine IP address range provided by the DHCP server is 192.168.56.2 – 192.168.56.100
- The IP address range available to the Guest machines for static addresses is 192.168.56.101 through 192.168.56.254.