Adding additional IPv4 to CentOS

This guide is applicable only for KVM based VPSes, for OpenVZ based VPSes please click here

To View Network Gateway and Netmask

To know the gateway and netmask of your IP address, please see this guide

Configuring additional IPv4

First, we need to find the name of the network interface on our server,

To find the name of the network interface, simply run the following cmd,

ip a

This will give you an output similar to,

[root@test-server ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 54:52:00:d7:74:ed brd ff:ff:ff:ff:ff:ff
    inet brd scope global noprefixroute dynamic ens3
       valid_lft 20732392sec preferred_lft 20732392sec
    inet6 fe80::5652:ff:fed7:74ed/64 scope link noprefixroute
       valid_lft forever preferred_lft forever

Here, we see that we have eth0 as our network interface, from the above example,

Other similar interfaces could be ens3, enp0s3 and many more.

If that's the case, you will have to replace eth0 with the interface name you have in your server for the following steps further in this guide.

Edit the interfaces file,

nano /etc/sysconfig/network-scripts/ifcfg-eth0:1

Add the following into it. (Replace the IP_ADDRESS,GATEWAY,NETMASK with your IP details)


Once the interfaces file is updated,

ifup eth0:1

Should activate up the interface with the new additional IP

To add more IPs,

  1. change ifcfg-eth0:1 to ifcfg-eth0:2, ifcfg-eth0:3, ifcfg-eth0:4 etc
  2. change DEVICE=eth0:1 to DEVICE=eth0:2, DEVICE=eth0:3, DEVICE=eth0:4 etc

in the files