When working with an Ubuntu virtual machine (VM), you may need to manually assign a secondary IP address. Below are the steps to achieve this.
First, attach public IP to the VM from the advance dashboard for details Click here
Then take access to your Ubuntu VM Before adding a secondary IP address, identify the network interface connected to your VM. Run the following command:
ip a
Edit the Netplan Configuration File
Ubuntu uses Netplan for network configuration. Find the Netplan YAML configuration file, usually located in /etc/netplan/
. Common filenames include 50-cloud-init.yaml
Open the configuration file in a text editor:
Modify the file to include the secondary IP under the correct network interface. Below is an example configuration:

Apply the Changes
To apply the new configuration, run:
netplan apply
You have successfully assigned a secondary IP to your Ubuntu VM