Using Cloudinit and Netplan with IP’s on a different Network and Gateway

If you ever had to use a hosting provider where you could purchase Additional IP’s or failover IP’s, you would have noticed that sometimes the IP’s used the same gateway as your original IP’s.

  • OVH
  • SoYouStart

The problem is when you use Cloudinit to deploy your VM’s on Ubuntu which uses netplan and unfortunately there isn’t a method to configure netplan through Cloudinit.

I’m using Proxmox and although you can create a custom network configuration for netplan.yml and deploy it as a snippet via cloudinit. This isn’t idea.

Canoical looks to have fixed the bug this year (2023) in January

However, that most likely relates to the new Ubuntu LTS. I’ve tested this within Ubuntu 20.04 and the appropriate config is in place. Here’s the generated /etc/netplan/50-cloud-init.yaml

[email protected]:~# cat /etc/netplan/50-cloud-init.yaml
# This file is generated from information provided by the datasource.  Changes
# to it will not persist across an instance reboot.  To disable cloud-init's
# network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
    version: 2
                macaddress: 02:00:00:79:e4:73
            -   on-link: true
                to: default
            set-name: eth0
            dhcp4: true
                macaddress: 8a:ca:d3:4d:c9:28
            set-name: eth1
    Reddit – Dive into anything
    BUG: No routing in VM with cloud init (ubuntu 18.x – 19.4) | Proxmox Support Forum
    It´s possible a bug in the network setting from proxmox to VMs with cloud-init and ubuntu. I have see many forum entries about the same problemas! The big…