Multipass from Canonical is a tool for quickly deploying VM’s (running Ubuntu) on the native Hypervisor, the VM also has a kernel optimized for the Hypervisor.
Pros and Cons
- Rapid provisioning with cloud-init
- Better performance than Virtualbox
- Difficult networking options (no bridge, no secondary network cards, no secondary IP addresses that work (some workarounds later)
First the basics
Create machines
$ multipass launch --name machine1 -d 8G -m 4192M -c 4
$ multipass launch --name machine2 -d 8G -m 1024M -c 1
Shell
$ multipass exec machine1 -- bash
List Machines
$ multipass list
Name State IPv4 Image
machine1 Running 192.168.64.2 Ubuntu 18.04 LTS
machine2 Running 192.168.64.3 Ubuntu 18.04 LTS
Problems with networking
Some things just don’t work very well. For example, using cloud-init to set a fixed IP address. The machine will ignore this and acquire a dhcp address from they hypervisor/bootp. Adding a second nic is not possible. Adding a second IP to the existing nic is possible but it will have limited functionality. Manually changing the IP will cause the multipass cmd to get disconnected from the VM making it hard to delete the VM or get a shell on it.
Workaround for static address on Mac
On your Mac after you have created a machine you will have a file called /var/db/dhcpd_leases this is where the machine gets its address from. Edit this file and assign the addresses you want (you must keep 192.168.). Restart your VM’s and they will be dynamically be assigned your static address.
sudo vi /var/db/dhcpd_leases
{
name=machine2
ip_address=192.168.64.102
hw_address=1,aa:74:48:50:b9:b9
identifier=1,aa:74:48:50:b9:b9
lease=0x5e7b72c5
}
{
name=machine1
ip_address=192.168.64.101
hw_address=1,56:2:58:38:b1:7d
identifier=1,56:2:58:38:b1:7d
lease=0x5e7b72c4
}
$ multipass list
Name State IPv4 Image
machine1 Running 192.168.64.101 Ubuntu 18.04 LTS
machine2 Running 192.168.64.102 Ubuntu 18.04 LTS
Other issues
DNS resolution becomes difficult if you use a VPN, but at least using the above and a hosts file you should be able to get by.
Nice article, i had install multipass on mac used hyperkit driver, then i installed lxd inside of vm multipass used lxdbr0. how to configure lxd so get ip from host mac (same as multipass 192.168.64.x), i tried using bridge on multipass and used on lxd but failed. any idea?
I’m not sure, I think hyperkit has some limits with how it allocates IP’s to the VM, so for example you can have 1 IP and all works, but if you add a 2nd it won’t work even for pings.
I’ll experiment with it again and write back here If I have any success.