Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save galaxy001/a3f300d1e00ac54f8cff0a3cb7e7883f to your computer and use it in GitHub Desktop.
Save galaxy001/a3f300d1e00ac54f8cff0a3cb7e7883f to your computer and use it in GitHub Desktop.
Ubuntu netplan config for secondary ip address

In case there's already a DHCP config for netplan for the private IP address:

File: /etc/netplan/50-cloud-init.yaml

Contents:

# This file is generated from information provided by
# the datasource.  Changes to it will not persist across an instance.
# 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:
    ethernets:
        ens3:
            addresses: []
            dhcp4: true
            optional: true
    version: 2

To add a secondary, public IP address:

Create /etc/netplan/60-static.yaml

Contents:

network:
  version: 2
  renderer: networkd
  ethernets:
    ens3:
      addresses:
        - 148.251.64.58/24

Then apply config:

netplan try

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment