Multipass, virt-manager and bridged network

13,943

Solution 1

Thanks for giving Multipass a try. In Multipass, we use Ubuntu cloud images by default, so there are a few things to be aware of. By default, cloud images do not have a user that has an enabled password. However, since they are cloud images, you can use cloud-init to provision your Multipass instance in many different ways. cloud-init documentation can be found at https://cloudinit.readthedocs.io/en/latest/. There are many examples in there for many different configurations. Also, there is a short blog post at https://ubuntu.com/blog/using-cloud-init-with-multipass about using cloud-init with Multipass.

Regarding the networking and multipass connections to the instance, yes, we require an ssh connection and as such, we need to be able to easily discover the IP address of the instance. The best way to use bridged networking would be to add a second interface via cloud-init and then point libvirt to this second interface for bridged networking and leave the NAT'd network intact so as multipass can connect to it.

I hope this helps and good luck!

Solution 2

I had a similar use case - In addition to using the SSH tools, I've found it to be very helpful for server use cases to use nginx as well, for the use case of hosting multipass VM's from a headless ubuntu server.

e.g. I'm running a rails webserver in a multipass VM on port 3000, and will link that with ssh onto port 9000 on my host, and be able to connect to my host from anywhere at <host ip>:8080

1. Link multipass to host
sudo ssh -L 9000:localhost:3000 \ 
    -i /var/snap/multipass/common/data/multipassd/ssh-keys/id_rsa \
    ubuntu@<multipass instance ip> 
2. Enable access to multipass externally from host

Now using nginx, I'm going to connect to port 9000 using the host's IP and expose that on port 8080 for external connections.

server {
    listen 8080;
    server_name development;
    location / {
        proxy_pass http://localhost:9000;
    }
}
Share:
13,943

Related videos on Youtube

Tom Davidson
Author by

Tom Davidson

Updated on September 18, 2022

Comments

  • Tom Davidson
    Tom Davidson almost 2 years

    I'm just starting to use Multipass, and I have found that some of the documentation is sparse (or I don't know how to find it properly). I am running 19.10, with QEMU and libvirt installed. I created a bridged Ethernet interface called br0 for a Windows 10 VM that I need on the same subnet as my other workstations. This part works fine. I ran the command "sudo multipass set local.driver=libvirt" and then created my first multipass instance.

    The first problem I had was that I had to use the multipass connect method to log into the VM and create a user (other than the default "ubuntu" user) and make the new user a member of sudo. This was because I could not figure out how to log into the VM via the virt-manager console as the multipass sudo user ubuntu. Once that was done, I was able to log into the virt-manager console as the new user, and install openssh-server. I shut down the VM, changed the NIC in virt-manager to the bridged Ethernet interface, restarted the VM and the VM received an IP from my DHCP server and was directly accessible from any other workstation or VM on the network via SSH.

    Unfortunately, doing this breaks the "multipass connect vm01" method of connecting to the VM (in fact, it breaks any multipass commands from the CLI that are directed at the instance) and the only way to connect now is via SSH (or the virt-manager console).

    Is there a configuration file somewhere for instructing multipass to look for the VM on the new bridged interface? I am actually fine with it operating as a standalone VM under virt-manager (in fact, it is a fantastic way to spin up an Ubuntu VM without creating a new VM in virt-manager, attaching an ISO, etc.). But I can foresee future problems with having broken the multipass CLI link to the instance.

    • guiverc
      guiverc over 4 years
      Ubuntu 19.04 is EOL (fridge.ubuntu.com/2020/01/23/…) thus off-topic on this site (askubuntu.com/help/on-topic) unless your question is specific to help moving to a supported release of Ubuntu. Use a LTS or long-term-support release if you don't like release-upgrading every 6-9 months
    • Tom Davidson
      Tom Davidson over 4 years
      I apologize - this was a typo. I am running 19.10. I will correct the original to reflect the typo.