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.
Before you start, ensure you have the following:
- A Cloudpap VM running CentOS 7.
- SSH access to your VM. We will assume you have root access and your VM IP is 10.10.245.3
- An additional IP address, such as 184.108.40.206 (your specific address may differ).
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.
You will be prompted to enter your password or provide your SSH key for authentication.
- 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
sudo vi /etc/sysconfig/network-scripts/ifcfg-enp1s0
Inside the configuration file, add the following lines:
Your final configuration file will look like this
DEVICE=enp1s0 BOOTPROTO=static ONBOOT=yes IPADDR=220.127.116.11 NETMASK=255.255.255.0 IPADDR=18.104.22.168
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
- 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:
If the ping is successful you will get an output as below
root@vm-xo:/etc/netplan# ping -c 422.214.171.124 ping: invalid argument: '4126.96.36.199' root@vm-0a790c31:/etc/netplan# 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