Tuesday, April 28, 2015

HOW TO ADD Multiple / Ranges OF IP ADDRESSES TO CentOS / RHEL / Oracle Linux

Go to the /etc/sysconfig/network-scripts directory.

#     cd /etc/sysconfig/network-scripts/

Verify which interface you will use to add IP addresses. Typically, this will be em1, em2 or eth0, eth1 for public IP addresses.

Make a copy of ifcfg-eth0 for each IP you wish to add and name them as ifcfg-eth0:0, ifcfg-eth0:1 etc.
#      cp ifcfg-eth0 ifcfg-eth0:0
#      cp ifcfg-eth0 ifcfg-eth0:1
#      cp ifcfg-eth0 ifcfg-eth0:2
#      cp ifcfg-eth0 ifcfg-eth0:3
#      cp ifcfg-eth0 ifcfg-eth0:4

Open each of them and change the fields DEVICE, .IPADDR and NETMASK accordingly.
A sample entry would look like this:
NAME="eth0:0"BOOTPROTO="static"IPADDR0="192.168.0.2"PREFIX0="23"ONBOOT=yesGATEWAY0="192.168.1.1"
Restart the network:

#    systemctl restart network
OR
#    service network restart

To add a lot of IP addresses ( range(s) ) at once:

#    cd /etc/sysconfig/network-scripts/

In this folder, create a file named "ifcfg-emX-rangeY", without the quotes, and replacing X with the ID of the physical interface, Y with the ID of the IP range. For example, to add range0 to em1, you would use the file name:     ifcfg-em1-range0

In the file, enter the following information, modifying the entries as necessary.
IPADDR_START=192.168.0.6
IPADDR_END=192.168.0.18
CLONENUM_START=0
NETMASK=255.255.254.0
IPADDR_START means the start of the IP address range
IPADDR_END means the end of the IP address range
CLONENUM_START means the number assigned to the first virtual interface, for example em2:8 or em2:88.

After you have created the file, save and quit, and then restart the network service:

#    systemctl restart network
OR
#    service network restart

Popular Posts

Labels

ad ( 5 ) Amazon ( 42 ) Answer ( 1 ) API ( 23 ) automation ( 1 ) blog ( 22 ) book ( 2 ) business ( 1 ) career ( 12 ) cdn ( 3 ) centos ( 1 ) cloud ( 125 ) CRM ( 24 ) current ( 15 ) data ( 17 ) database ( 65 ) design patterns ( 17 ) development ( 3 ) document ( 1 ) eCommerce ( 26 ) email ( 93 ) ETL ( 2 ) file ( 1 ) framework ( 3 ) git ( 11 ) google ( 180 ) IDE ( 18 ) Integration ( 1 ) interview ( 16 ) Java ( 408 ) Java EE ( 108 ) javascript ( 42 ) Jboss ( 4 ) JPA ( 51 ) JSF ( 44 ) linux ( 337 ) Marketing ( 21 ) mobile ( 45 ) model ( 1 ) MySQL ( 199 ) online money ( 16 ) OOP ( 7 ) open source ( 26 ) performance ( 73 ) php ( 51 ) python ( 46 ) quality ( 6 ) referral ( 3 ) restful ( 23 ) security ( 139 ) SEO ( 19 ) social ( 27 ) software ( 76 ) spam ( 4 ) Spring ( 1 ) SQL ( 22 ) system ( 34 ) testing ( 17 ) tool ( 96 ) UML ( 8 ) virtual ( 10 ) web ( 234 ) web services ( 14 ) WildFly ( 5 ) wordpress ( 12 )