In some scenarios the default of using the system-provided DNS will not be sufficient. When that’s the case, you can use the
--cloud-init option to the
launch command, or modify the networking configuration after the instance started.
To use a custom DNS in your instances, you can use this cloud-init snippet:
#cloud-config bootcmd: - printf "[Resolve]\nDNS=220.127.116.11" > /etc/systemd/resolved.conf - [systemctl, restart, systemd-resolved]
18.104.22.168 with whatever your preferred DNS server is. You can then launch the instance using the following:
$ multipass launch --cloud-init systemd-resolved.yaml
The netplan.io approach
After the instance booted, you can modify the
/etc/netplan/50-cloud-init.yaml file, adding the
network: ethernets: ens3: dhcp4: true match: macaddress: 52:54:00:fe:52:ee set-name: ens3 nameservers: search: [mydomain] addresses: [22.214.171.124]
You can then test it:
$ sudo netplan try Do you want to keep these settings? Press ENTER before the timeout to accept the new configuration Changes will revert in 120 seconds ...