how to Assign Multiple IP Addresses to One Single Network Interface in Linux

The concept of creating or configuring multiple IP addresses on a single network interface is called IP aliasing. IP aliasing is very useful for setting up

Source: Create Multiple IP Addresses to One Single Network Interface

Assign Multiple IP Addresses to One Single Network Interface

  1. The device network (NIC) files located in “/etc/sysconfig/network-scripts/” directory.
  2. Navigate to the directory and do “ls -l” to list all devices.

                cd /etc/sysconfig/network-scripts/

ls –l

[root@******** network-scripts]# ls -l

total 236

-rw-r–r–. 1 root root   394 Nov  5 13:13 ifcfg-ens192

  1. Copy existing parameters of interface “ifcfg- ens192” in virtual interfaces called ifcfg- ens192:0, ifcfg- ens192:1 and ifcfg- ens192:2.

cp ifcfg- ifcfg-ens192 ifcfg- ifcfg-ens192:0

                                cp ifcfg- ens192 ifcfg- ens192:1

                                cp ifcfg- ens192 ifcfg- ens192:2

  1. edit each file and rename the DEVICE name to its corresponding alias and change the IPADDR address.

For example:

DEVICE=” ens192 ” replace with ens192:0

BOOTPROTO=static

ONBOOT=yes

TYPE=”Ethernet”

IPADDR=172.16.16.125 replace with the new virtual IP.

NETMASK=255.255.255.224

GATEWAY=172.16.16.100

HWADDR=00:0C:29:28:FD:4C

  1. Once, you’ve made all changes, save all your changes and restart/start the network service for the changes to reflect.

[root@*************]# /etc/init.d/network restart

How to Assign Multiple IP Address Range

  1. if you would like to create a range of Multiple IP Addresses to a particular interface called “ifcfg-eth0“.

cd /etc/sysconfig/network-scripts/

cp -p ifcfg-eth0 ifcfg-eth0-range0

  1. Now open “ifcfg-eth0-range0” file and add “IPADDR_START” and “IPADDR_END” IP address range as shown below.

[root@***********]# vi ifcfg-eth0-range0

 

#DEVICE=”eth0″

#BOOTPROTO=none

#NM_CONTROLLED=”yes”

#ONBOOT=yes

TYPE=”Ethernet”

IPADDR_START=172.16.16.126

IPADDR_END=172.16.16.130

IPV6INIT=no

#GATEWAY=172.16.16.100

  1. Save it and restart/start network service

[root@**************]# /etc/init.d/network restart

Leave a comment