Adding a single secondary IP on CentOS is fairly straight forward.
Adding a single secondary IP
Assuming that you want the secondary IP on your first ethernet card (eth0), create a file /etc/sysconfig/network-scripts/ifcfg-eth0:1 with the following content:
user@laptop:~$ cat /etc/sysconfig/network-scripts/ifcfg-eth0:1 DEVICE=eth0:1 ONBOOT=yes BOOTPROTO=static IPADDR=10.10.10.100
Optionally, you can also set NM_CONTROLLED to yes if you’d like network manager to control it
Adding multiple secondary IPs
However, there are use cases when you need to assign bulk multiple IP addresses. For example, I want my server to have IP address 10.10.10.100 to 10.10.10.200. Making 100 files ifcfg-eth0:1 … ifcfg-eth0:100 just doesn’t make sense and not maintainable. Fortunately, there’s an easy way to do that.
user@laptop:~$ cat /etc/sysconfig/network-scripts/ifcfg-eth0-range TYPE=Ethernet ONBOOT=yes BOOTPROTO=static IPADDR_START=10.10.10.101 IPADDR_END=10.10.10.200
I started from 101 because IP 10.10.10.100 is configured from ifcfg-eth0 file.
So there you have it. As always, I welcome comments / questions / critics that will help me and other readers understand better.