Configure additional IPs CentOS KVM NVMe
Because of our network configuration and the way our KVM NVMe VPS servers are configured, to get any additional IPs or subnets to ping inside your virtual container and be accessible from the outside you need to add separate network interfaces for each additional IP.
If you have a subnet you could also use a range file to deploy the whole subnet to the server. This would save time having to create an interface for each IP. This guide will also work on CentOS Dedicated Servers.
This setup guide relates to our network and will not work with other providers. This is the manual way of configuring additional IPs.
Configure Additional IPs In CentOS
Firstly we take a copy of the eth0 file;
cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0:0
Now we can edit this file, don’t worry if you make a mistake as this is a secondary device it won’t harm the connection to your guest virtual machine.
You will now see the device configuration which should be like this, your screen will show DEVICE=eth0.
Change the values in this file to reflect the below. Just delete everything and copy the below code. Replace Additional IP with your IP address.
#NM_CONTROLLED="no" DEVICE=eth0:0 BOOTPRONTO=static ONBOOT=yes IPADDR=ADDITIONAL IP BROADCAST=ADDITIONAL IP NETMASK=255.255.255.255
Additional IPs CentOS 7 / 8
For CentOS 7 or CentOS 8 KVM servers, you will need to ensure Network Manager is disabled for additional interfaces. If your server is running CentOS 7 remove the # from the above code. Remember to add your IP address. The file will look like this;
NM_CONTROLLED="no" DEVICE=eth0:0 BOOTPRONTO=static ONBOOT=yes IPADDR=ADDITIONAL IP BROADCAST=ADDITIONAL IP NETMASK=255.255.255.255
Remove any reference to “GATEWAY” there is no need to specify a gateway as all additional IPs will be routed to the MAC address of your NVMe VPS
Save and close that file.
Next all that’s needed to be done is to bring the additional network interface up. Run the below command
That’s the process complete and you can repeat this process to add more additional IPs.
Configure further IPs to Your Server
To add further IPs to your guest machine simply add more network devices. Each device should have a different eth0 and IP.
DEVICE=eth0:1 BOOTPRONTO=static ONBOOT=yes IPADDR=ADDITIONAL IP BROADCAST=ADDITIONAL IP NETMASK=255.255.255.255
After adding each device remember to run
*Make sure you swap the eth0:1 for the correct device you specify in the device file.
You should now be able to ping your IP. If you can’t please contact our support team who will check the routing of your additional IPs or subnet.
How was this article? – Adding additional IPs KVM CentOS virtual machine
More from Dedicated Servers
Cloud-init is a popular way to automate deployments of instances in a cloud or none cloud environment. To save having …
Ioncube Loaders are a piece of software that is used to protect the underlying code in PHP applications. Its aim …