Skip links

How to Configure an Additional IP on a CentOS 7 Cloudpap VM

View Categories

How to Configure an Additional IP on a CentOS 7 Cloudpap VM

2 min read

Table of Contents

Introduction #

In the realm of cloud computing, the need for additional IP addresses on your virtual machine (VM) can arise for various purposes. 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 CentOS 7 Cloudpap VM.

Prerequisites #

Before you start, ensure you have the following:

  1. A Cloudpap VM running CentOS 7.
  2. SSH access to your VM. We will assume you have root access and your VM IP is 10.10.245.3
  3. An additional IP address, such as 102.212.245.5 (your specific address may differ).

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.

ssh [email protected]

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

  1. Add an extra IP address

To add an additional IP address to a CentOS 7 VM, you’ll need to modify the network configuration. CentOS 7 typically uses the NetworkManager service for this purpose.

Open the network configuration file using a text editor. In this example, we’ll use vi:

sudo vi /etc/sysconfig/network-scripts/ifcfg-enp1s0

Inside the configuration file, add the following lines:

IPADDR=102.212.245.5

Your final configuration file will look like this

DEVICE=enp1s0
BOOTPROTO=static
ONBOOT=yes
IPADDR=102.212.245.3
NETMASK=255.255.255.0
IPADDR=102.212.245.5

Ensure that you replace the values with your specific configuration.

Save your changes and exit the text editor.

Now, you need to restart the network service to apply the changes:

sudo systemctl restart network
  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:

ping 102.212.245.5

If the ping is successful you will get an output as below

root@vm-xo:/etc/netplan# ping -c 4102.212.246.88
ping: invalid argument: '4102.212.246.88'
root@vm-0a790c31:/etc/netplan# ping -c 4 102.212.246.88
PING 102.212.246.88 (102.212.246.88) 56(84) bytes of data.
64 bytes from 102.212.246.88: icmp_seq=1 ttl=64 time=0.018 ms
64 bytes from 102.212.246.88: icmp_seq=2 ttl=64 time=0.056 ms
64 bytes from 102.212.246.88: icmp_seq=3 ttl=64 time=0.069 ms
64 bytes from 102.212.246.88: icmp_seq=4 ttl=64 time=0.031 ms

--- 102.212.246.88 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