The VMs are in the same Local Area Network,they can visit each other.Hello World!!!!!世界，你好！
The VMs’ network is separated from the Host Machine’s network.
The VMs can visit the Internet.
The VMs and the Host Machine can visit each other.
We’ll use two Adapters in the VM: Adapter 1 (with NAT configuration) is used to visit the Internet, and the Adapter 2(with Host-only configuation) is used to build a Private Network.
Step By Step
Host Computer：MacOS Catalina (Version 10.15.5)
Please download and install the free VirtualBox Software:
VirtualBox: VirtualBox 6.1.16 for OSX
Download Virtual Machine ISO file from ubuntu offical site:
Virtual Machine: ubuntu-20.04.1-live-server-amd64
Step1 Create a Host Only Network in VirtualBox
Open “Host Network Manager” from the VirtualBox menu “File”->”Host Network Manager…”，and click “Create” button to create a Host Only Network. You can Enable the DHCP Server. I disabled the DHCP Server because I want to have a fixed static ip address rather than a dynamic ip address.
Step2 Create a New Virtual Machine
Please follow the guild on VirtualBox manual to install a new virtual machine base on ubuntu iso file.
Step3 Config the Host Only Network
Please “shutdown” your virtual machine first,and then click “setting”->”network”:
It has had a default NAT configuration in Adapter 1, we need to config another Adapter, so just click the “Adapter 2” tab, and select the “Enable Network Adapter” checkbox. We can use the Host-only Adapter with the “vboxnet0” that is configured in the previous steps. At last, click “OK”:
Step4 Configure the ip address of the Virtual Machine
Just start your virtual machine and login to your ubuntu operation system. Confirm your network interfaces, for example, I have a enp0s8 interface as the Host-only Adapter, next step I will configure this interface’s ip address:
Create a network configuration file in the /etc/netplan/ directory, for example:.
Here is the file content:
And let the configurations work:
$sudo netplan apply
You can test if the VM is connect with the Host:
Ping Host Machine in your Virtual Machine:
Ping Virtual Machine in your Host Machine:
And you can add another Virtual Machine with these steps!