To add newly assigned IP addresses from SSH, follow this procedure:
Open SSH and go to /etc/sysconfig/network-scripts/
# cd /etc/sysconfig/network-scripts/
Verify which interface you will use to add IP addresses. Typically, this will be eth0 for public IP addresses.
# cat ifcfg-eth0
This will produce output similar to the following:
DEVICE="eth0" BOOTPROTO="static" DNS1="8.8.8.8" DNS2="8.8.4.4" GATEWAY="72.82.1.13" HOSTNAME="nile102.nilehoster.com" HWADDR="00:25:90:D5:BB:05" IPADDR="72.82.1.14" IPV6INIT="no" MTU="1500" NETMASK="255.255.255.248" NM_CONTROLLED="yes" ONBOOT="yes" TYPE="Ethernet" UUID="a0f44359-fe68-49b1-a87c-e6458d1a35c8"
Make a copy of ifcfg-eth0 for each IP you wish to add and name them as ifcfg-eth0:0, ifcfg-eth0:1, ifcfg-eth0:2 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. (IPADDR and NETMASK should be provided by your hosting provider)
A sample entry would look like this:
DEVICE=eth0:0 BOOTPROTO=static IPADDR=34.123.111.21 NETMASK=255.255.255.0 ONBOOT=yes
Restart the network:
# /etc/init.d/network restart
To verify what are the IP addresses assigned to your server, please use the following command:
# /sbin/ifconfig
Adding range of IPs at once
Navigate to the following location:
# cd /etc/sysconfig/network-scripts/
Create a file with this name “ifcfg-eth0-range” using “nano” editor for example:
# nano ifcfg-eth0-range
Past the following content:
IPADDR_START=10.0.0.1
IPADDR_END=10.0.0.100
CLONENUM_START=0
NETMASK=255.255.255.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 eth0:0 or eth0:1, or eth0:8 , if there are no IPs added previously, you can set it to “1”
NETMASK is 255.255.255.255 for all secondary IP addresses to allow you to use the network and broadcast addresses on your server (Provided by your hosting provider)
And finally, restart network:
# /etc/init.d/network restart