Logon as root and display network interfaces :

[root@localhost ~]# ip link show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eno16777984: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000
    link/ether 00:0c:29:6c:16:cb brd ff:ff:ff:ff:ff:ff

We already have an I.P. address on “eno16777984” interface, as follows :

[root@localhost ~]# ip add show dev eno16777984
2: eno16777984: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:0c:29:6c:16:cb brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.201/24 brd 192.168.1.255 scope global eno16777984
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:29ff:fe6c:16cb/64 scope link
       valid_lft forever preferred_lft forever

To add several I.P. address aliases, go to this directory :

[root@localhost ~]# cd /etc/sysconfig/network-scripts

You must create 1 file “interface:increment” per alias.

For the first alias :

[root@localhost network-scripts]# cat ifcfg-eno16777984:0
TYPE=Ethernet
BOOTPROTO=static
IPADDR=192.168.1.211
NETMASK=255.255.255.0
IPV4_FAILURE_FATAL=no
IPV6INIT=no
NAME=eno16777984:0
DEVICE=eno16777984:0
ONBOOT=yes

For the second one :

[root@localhost network-scripts]# cat ifcfg-eno16777984:1
TYPE=Ethernet
BOOTPROTO=static
IPADDR=192.168.1.221
PREFIX=24
IPV4_FAILURE_FATAL=no
IPV6INIT=no
NAME=eno16777984:0
DEVICE=eno16777984:0
ONBOOT=yes

And so on …

Remark : CentOS supports both :

  • legacy netmask option :
NETMASK=255.255.255.0
  • new prefix option :
PREFIX=24

Restart network service to update the interfaces :

[root@localhost network-scripts]# systemctl restart network.service

You will your 3 I.P. addresses on the same interface :

[root@localhost network-scripts]# ip addr show dev eno16777984
2: eno16777984: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:0c:29:6c:16:cb brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.201/24 brd 192.168.1.255 scope global eno16777984
       valid_lft forever preferred_lft forever
    inet 192.168.1.211/24 brd 192.168.1.255 scope global secondary eno16777984:0
       valid_lft forever preferred_lft forever
    inet 192.168.1.221/24 brd 192.168.1.255 scope global secondary eno16777984:1
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:29ff:fe6c:16cb/64 scope link
       valid_lft forever preferred_lft forever

 

tools.pdf24.org    Send article as PDF   

Leave a Reply

Your email address will not be published. Required fields are marked *


*