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

If you’ve ever had to utilize a hosting provider that offers the option to buy extra IPs or failover IP addresses, you may have observed instances where these IPs shared the same gateway as your original IPs, rather than being part of the additional IP network.

Here are some of the providers I’m aware of that require this.

  • 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 to use a gateway that isn’t on the same network as the IP address.

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 ideal.

Canonical looks to have fixed the bug this year (2023) in January https://github.com/canonical/cloud-init/pull/1931

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

root@srv01:~# 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}
network:
    version: 2
    ethernets:
        eth0:
            addresses:
            - 147.135.0.0/24
            match:
                macaddress: 02:00:00:79:e4:73
            nameservers:
                addresses:
                - 213.186.33.99
                search:
                - domain.com
            routes:
            -   on-link: true
                to: default
                via: 15.0.0.254
            set-name: eth0
        eth1:
            dhcp4: true
            match:
                macaddress: 8a:ca:d3:4d:c9:28
            set-name: eth1
    Reddit – Dive into anything
    www.reddit.com
    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…
    forum.proxmox.com

    https://linuxconfig.org/how-to-add-static-route-with-netplan-on-ubuntu-22-04-jammy-jellyfish-linux

    Setting up Proxmox Email Alerts

    Introduction

    You may not have known, but Proxmox does send out emails every so often. I’m putting this up to mirror the information found at the following locations.

    https://crepaldi.us/2021/03/07/configuring-e-mail-alerts-on-your-proxmox/

    1. Install the authentication library

    apt-get install libasal2-modules

    2. Choose an SMTP Provider

    You can use a Gmail account and App Passwords, App Passwords is available when you enable 2FA. I use Postmark, because it’s the best out there and I don’t mind paying.

    3. Create a password file

    nano /etc/postfix/sasl_passwd

    4. Insert your login details

    smtp.gmail.com [email protected]:yourpassword

    5. Save the password file

    6. Create a database from the password file

    postmap hash:/etc/postfix/sasl_passwd

    7. Protect the text password file

    chmod 600 /etc/postfix/sasl_passwd

    8. Edit the postfix configuration file

    nano /etc/postfix/main.cf

    9. dd/change the following (certificates can be found in /etc/ssl/certs/):

    relayhost = smtp.gmail.com:587 smtp_use_tls = yes smtp_sasl_auth_enable = yes smtp_sasl_security_options = smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd smtp_tls_CAfile = /etc/ssl/certs/Entrust_Root_Certification_Authority.pem smtp_tls_session_cache_database = btree:/var/lib/postfix/smtp_tls_session_cache smtp_tls_session_cache_timeout = 3600s

    10. Reload the updated configuration

    postfix reload

    11. Testing

    echo "test message" | mail -s "test subject" [email protected]

    Dell OSMA on Proxmox/Debian Buster

    I found a Reddit post that I wanted to make sure I kept in case it gets deleted and lost forever.

    My Issue

    I have some Dell servers that I wanted to enable iDRAC on remotely via a secondary network interface. Unfortunately, I didn’t have physical access. So I needed to use OSMA to enable iDRAC and configure the necessary network details.

    Proxmox and Dell OSMA

    If you have a Dell server and you want to be able to use the OSMA (Dell EMC OpenManage Server Administrator) on your Proxmox server. Here’s a quick guide that someone posted on Reddit and on the Proxmox forums.

    WARNING

    The code below on the Proxmox forums works, but the Reddit code doesn’t.

    Since the code is half-baked on both. I’ve maintained my own version.

    https://forum.proxmox.com/threads/dell-openmanage-on-proxmox-6-x.57932/

    ProxMox CIFS Share error “failed: error with cfs lock ‘file-storage_cfg'”

    You may have encountered the following error message when trying to mount a CIFS share from the web interface of your Proxmox server. If you run the following command below via SSH, you will get a little more detail.

    ❯ pvesm add cifs pooter-linux-isos --server 192.168.2.9 --share linux-isos --username proxmox --password
    Enter Password: *********
    mount error(95): Operation not supported
    create storage failed: error with cfs lock 'file-storage_cfg': mount error: Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)

    The issue is solved by running the command with –smbversion 2.0 or 2.1 or 3.0 as per this forum topic. For my Synology it was –smbversion 2.0 that worked.

    https://forum.proxmox.com/threads/cifs-issue-error-with-cfs-lock-file-storage_cfg-working-now-but-shows-question-mark.45962/