Add multiple IP’s to a Linux Box

I will try to explain in here an easy way to add a lot of IP’s to a server without having to add every one of them manually but of course this works if IP’s are part of same classes.

For example if you want to add a few IP’s from the 192.168.20.0 class:

[root@JobNix ~]# cd /etc/sysconfig/network-scripts/ – this is where the network settings are being searched for

[root@JobNix network-scripts]# vi ifcfg-eth0-range0 – this will be the file where we define the new IP class(considering that our main interface is called eth0)

Add this content to the file:

IPADDR_START=192.168.20.1
IPADDR_END=192.168.20.100
CLONENUM_START=1
NETMASK=255.255.255.0

Explanation:

IPADDR_START – the first IP of the class you want to add

IPADDR_END – last IP of the class you want to add

CLONENUM_START – the number with which the virtual interface will start, this will create the virtual interfaces eth0:1 to eth0:28.

If you have more classes that you want to add on the next class CLONENUM will start at 29.

NETMASK – the mask for the IP class

After all this was added to the file and edited accordingly just save and restart the network.

Next class will be added same way only that you create a new file for it:

[root@JobNix network-scripts]# vi ifcfg-eth0-range1

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x
Scroll to Top