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 here
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 127.0.0.1/8 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 104.194.215.70/24 brd 104.194.215.255 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/Create the interfaces file,
nano /etc/sysconfig/network-scripts/ifcfg-eth0:1
And add the following into it. (Replace the IP_ADDRESS,GATEWAY,NETMASK with your IP details)
DEVICE=eth0:1
BOOTPROTO=static
IPADDR=IP_ADDRESS
GATEWAY=GATEWAY
NETMASK=NETMASK
ONBOOT=yes
Once the interfaces file is updated run,
ifup eth0:1
For CentOS 8, AlmaLinu 8, RockyLinux 8 you may need to run below command to restart network,
systemctl restart NetworkManager
Or
nmcli networking off && nmcli networking on
or
reboot the server
Should activate up the interface with the new additional IP
To add more IPs,
- change ifcfg-eth0:1 to ifcfg-eth0:2, ifcfg-eth0:3, ifcfg-eth0:4 etc
- change DEVICE=eth0:1 to DEVICE=eth0:2, DEVICE=eth0:3, DEVICE=eth0:4 etc
in the files
CrownCloud - Get a SSD powered KVM VPS at $4.5/month!
Use the code WELCOME
for 10% off!
1 GB RAM / 25 GB SSD / 1 CPU Core / 1 TB Bandwidth per month
Available Locations: LAX | MIA | ATL | FRA | AMS