Bookmark and Share

Add multiple secondary IP addresses on CentOS

Posted: Tuesday, August 26th, 2014 at 10:11 pmUpdated: Tuesday, August 26th, 2014 at 10:11 pm

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

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 to 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

I started from 101 because IP 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.

Leave a Reply

Time limit is exhausted. Please reload the CAPTCHA.