multipass icon indicating copy to clipboard operation
multipass copied to clipboard

Add ability to add `--network`s to existing instances

Open Saviq opened this issue 2 years ago • 3 comments

@Saviq can confirm the Networks option is there now. Is there documentation somewhere for how to add a network/launch option to an existing instance? I'd like to either add --network bridged or a specific network interface to my existing microk8s-vm instance since I'm not sure I can have the MicroK8S installer pass the network options into multipass during the install process.

Originally posted by @mlb5000 in https://github.com/canonical/multipass/issues/1857#issuecomment-1063118209

Saviq avatar Mar 09 '22 16:03 Saviq

Thanks @Saviq !

mlb5000 avatar Mar 09 '22 18:03 mlb5000

@mlb5000 I've made this into a new issue.

We'll be adding that functionality in the long run for sure, but for now you'd need to edit our instance database.

This should do:

# stop the instance
$ multipass stop microk8s

# stop multipass
$ sudo launchctl unload /Library/LaunchDaemons/com.canonical.multipassd.plist

Edit /var/root/Library/Application\ Support/multipassd/qemu/multipassd-vm-instances.json and add something along those lines to the dictionary of the instance in question:

        "extra_interfaces": [
            {
                "auto_mode": false,
                "id": "en0",
                "mac_address": "52:54:00:ab:c3:0d"
            }
        ],

NB: make sure the MAC address is unique.

# start multipass
$ sudo launchctl load /Library/LaunchDaemons/com.canonical.multipassd.plist

$ multipass start microk8s

You will then need to configure the interface inside the instance, see https://netplan.io/examples/#connecting-multiple-interfaces-with-dhcp for some help.

Saviq avatar Mar 09 '22 19:03 Saviq

thanks Saviq on the solution. I managed to modify the instance's setting to add a DHCP enabled IP.

yipwt79 avatar Sep 08 '22 06:09 yipwt79

@Saviq Can confirm that this added the interface, but a couple things:

  1. That interface was disabled when the VM started back up. I had to explicitly run sudo ifconfig enp0s2 up before it would start.
  2. Despite setting the configuration "auto_mode": true, it did not automatically get an IP upon starting. I had to run sudo dhclient enp0s2 -v before it would get an IP from the DHCP server.

mlb5000 avatar Feb 20 '23 17:02 mlb5000

@mlb5000 that's this bit:

You will then need to configure the interface inside the instance, see https://netplan.io/examples/#connecting-multiple-interfaces-with-dhcp for some help.

Saviq avatar Feb 20 '23 17:02 Saviq

@Saviq ah oh great, then that's expected behavior. thanks for the response!

mlb5000 avatar Feb 20 '23 17:02 mlb5000

multipassd

how to do this in windows host? thank you

tsulatsitamim avatar Apr 16 '23 00:04 tsulatsitamim