How to add an extra IP to your KVM

VPS > KVM

If you order an extra IP for your KVM that new IP will not be added to the network settings of your server automatically. You have to add the new IP manually.

Before you can add any new or changed IP to your VPS please make sure you reboot the machine to make sure the VPS gets the new IP assigned.

! Please note that the following steps are not necessary for OpenVZ and VRS servers. Unlike for KVM, in OpenVZ and VRS IP addresses are automatically added to the containers.
 
Here are some examples how to add a secondary IP to your KVM.

DEBIAN / UBUNTU:

For example: If your server has a primary IP 192.168.1.1 on eth0 and you want to add a second IP that is 192.168.1.2. Then you edit the /etc/network/interfaces file like this:

auto eth0
iface eth0 inet static
  address 192.168.1.1
  netmask 255.255.255.0
  gateway 192.168.1.254
  post-up ip a a 192.168.1.2/24 dev eth0
  pre-down ip a d 192.168.1.2/24 dev eth0
After editing you run the command sudo ifup eth0:0 to activate the new interface.
 

CENTOS:

For example: If your server has a primary IP 192.168.1.1 on eth0 and you want to add a second IP that is 192.168.1.2You will need to be the root user and navigate to your /etc/sysconfig/network-scripts
 
In the folder you see you network interface config file(s).
# ls -l | grep ifcfg-eth
-rw-r--r-- 1 root root   119 Jan 11 19:16 ifcfg-eth0
Copy the primary adapter configuration file and name it to be the first virtual adapter
# cp ifcfg-eth0 ifcfg-eth0:0
# ls -l | grep ifcfg-eth
-rw-r--r-- 1 root root   119 Jan 11 19:16 ifcfg-eth0
-rw-r--r-- 1 root root   119 Feb 24 08:53 ifcfg-eth0:0
Edit the file ifcfg-eth0:0 and configure this virtual adapter to be: a static IP, no hardware address (MAC), configure netmask and rename the device.
DEVICE=eth0:0
BOOTPROTO=static
ONBOOT=yes
IPADDR=192.168.1.2
NETMASK=255.255.255.0
After editing you will have to restart the networking service with the command service network restart
 
 
 

Add Feedback