I am using CentOS 7.6 version. This article describes how to add multiple IPs to the same network interface. Different versions may have different methods.
Step 1: Go to the directory where the network configuration file is located
cd /etc/sysconfig/network-scripts/
In this directory, find the file in ifcfg-XXX format. In my system, this file is ifcfg-eth0.
Step 2: Open the network settings file.
nano ifcfg-eth0
After opening, you will see the following content:
DEVICE=ens33
BOOTPROTO=static
ONBOOT=yes
IPADDR=127.0.0.0(Beware of evil players)
NETMASK=255.255.255.0
GATEWAY=127.0.0.0(Beware of evil players)
DNS1=8.8.8.8
DNS2=8.8.4.4
I want to add one more IP now, 127.0.0.1 (Beware of bad players)
The contents of the modified ifcfg-eth0
are as follows:
DEVICE=ens33
BOOTPROTO=static
ONBOOT=yes
IPADDR=127.0.0.0(Beware of evil players)
IPADDR1=127.0.0.1
NETMASK=255.255.255.0
GATEWAY=127.0.0.0(Beware of evil players)
DNS1=8.8.8.8
DNS2=8.8.4.4
Note that I am only different on one line above. Just add more with the line IPADDR1=127.0.0.1, if you want to add another IP 127.0.0.2, add IPADDR2=127.0.0.2, and so on.
Save the file. You can restart the machine or run systemctl restart network to reset the network.
Recommended Posts