VirtualBox MacOS add Host-only network to Ubuntu VM

VirtualBox -> Preferences -> Network -> “+”. Should add a network interface called vboxnet0.

UbuntuVM -> Settings -> Network -> “Adapter N” -> Attached to (change to Host-only). Select vboxnet0.

In Ubuntu VM:

sudo ifconfig ethN 192.168.20.1

In MacOS:

sudo ifconfig vboxnet0 192.168.20.2