Skip links

How to Configure an Additional IPv4 on a Debian/Ubuntu Cloudpap VM Using Netplan

How to Configure an Additional IPv4 on a Debian/Ubuntu Cloudpap VM Using Netplan

Table of Contents

Introduction #

In the dynamic world of cloud computing, the need for additional IP addresses on your virtual machine (VM) can arise for various reasons. Whether you want to host multiple websites or improve network segmentation, this article will guide you through the process of configuring an extra IP address on a Debian/Ubuntu Cloudpap VM using Netplan, a modern network configuration tool.

Prerequisites #

Before you start, ensure you have the following:

  1. A Cloudpap VM running Debian or Ubuntu.
  2. SSH access to your VM. We’ll assume you have root access and your VM IP is
  3. An additional IP address. We’ll use as our IP in this case

Let’s get started:

  1. Login to your server via SSH

Begin by establishing an SSH connection to your VM. Use a terminal application on your local computer to log in. Replace with your VM’s actual IP address and root with your SSH username.

ssh [email protected]

You will be prompted to enter your password or provide your SSH key for authentication.

  1. Add an extra IP address using Netplan

Netplan is the modern way to manage network configuration in Debian/Ubuntu-based systems. To add an additional IP address, we’ll modify the Netplan configuration. Create a new Netplan configuration file with your additional IP using your preferred text editor. In this example, we’ll use vim:

sudo vim /etc/netplan/50-cloud-init.yaml

Inside the configuration file, add the following lines, ensuring the indentation is correct:

  version: 2
  renderer: networkd
      dhcp4: false
        macaddress: 02:00:00:xx:xx:xx
        - to: default
          metric: 100
        addresses: [,]

additional_addresses is where you specify the additional IP address, such as, and its subnet mask /32 for a single IP address.

Save your changes and exit the text editor.

Apply the Netplan configuration by running:

sudo netplan apply

  1. Test the additional IP

Before using the new IP, verify its functionality by pinging it from an external network or performing other tests.

On your VM, open a terminal and execute the following command:


Successful output should be as below

root@vm-xo:# ping -c 4
PING ( 56(84) bytes of data.
64 bytes from icmp_seq=1 ttl=64 time=0.018 ms
64 bytes from icmp_seq=2 ttl=64 time=0.056 ms
64 bytes from icmp_seq=3 ttl=64 time=0.069 ms
64 bytes from icmp_seq=4 ttl=64 time=0.031 ms

--- ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3058ms
rtt min/avg/max/mdev = 0.018/0.043/0.069/0.020 ms