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.
Before you start, ensure you have the following:
- A Cloudpap VM running Debian or Ubuntu.
- SSH access to your VM. We’ll assume you have root access and your VM IP is 10.10.245.3
- An additional IP address. We’ll use 10.10.245.5 as our IP in this case
Let’s get started:
- 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 10.10.245.3 with your VM’s actual IP address and
root with your SSH username.
You will be prompted to enter your password or provide your SSH key for authentication.
- 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
sudo vim /etc/netplan/50-cloud-init.yaml
Inside the configuration file, add the following lines, ensuring the indentation is correct:
network: version: 2 renderer: networkd ethernets: enp1s0: addresses: - 10.212.245.3/32 dhcp4: false match: macaddress: 02:00:00:xx:xx:xx routes: - to: default via: 10.212.245.1 metric: 100 nameservers: addresses: [220.127.116.11, 18.104.22.168] additional_addresses: - 22.214.171.124/32
additional_addresses is where you specify the additional IP address, such as
126.96.36.199, 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
- 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 188.8.131.52 PING 184.108.40.206 (220.127.116.11) 56(84) bytes of data. 64 bytes from 18.104.22.168: icmp_seq=1 ttl=64 time=0.018 ms 64 bytes from 22.214.171.124: icmp_seq=2 ttl=64 time=0.056 ms 64 bytes from 126.96.36.199: icmp_seq=3 ttl=64 time=0.069 ms 64 bytes from 188.8.131.52: icmp_seq=4 ttl=64 time=0.031 ms --- 184.108.40.206 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