Saltar al contenido

¿Cómo puedo añadir direcciones IP adicionales en CentOS con Whm?

Adding a Single IP Address

Adding an IP address to your server requires an ifcfg-eth0:x file to be created in /etc/sysconfig/network-scripts for each address you wish bind. For example, if you are adding a secondary IP address, the easiest way is to copy an existing ifcfg and then edit its contents. In this example we will create a new ifcfg-eth0:0 and then open it for editing:

cd /etc/sysconfig/network-scripts
cp ifcfg-eth0 ifcfg-eth0:0
vi ifcfg-eth0:0

The ifcfg-eth0:0 should look something like:

DEVICE=eth0
BOOTPROTO=static
ONBOOT=yes
IPADDR=192.168.1.100
NETMASK=255.255.255.128

If you are adding the IP address 192.168.1.101, you will change the IPADDR value to 192.168.1.101. Finally we must edit DEVICE to represent our new IP alias by changing it to eth0:0. This is what the complete file should now resemble:

DEVICE=eth0:0
BOOTPROTO=static
ONBOOT=yes
IPADDR=192.168.1.101
NETMASK=255.255.255.128

To add even more IP addresses, you should create a file for each one (such as ifcfg0:1, ifcfg0:2, ifcfg0:3, and so on) and edit it per this example. Then restart the network service to make your changes active:

service network restart

Adding Multiple IP Addresses

If you are assigned a large block of IP addresses it becomes impractical and time consuming to add them one-by-one as explained above. This is accomplished by creating a range file. To check if a range file already exists on your server simply enter in the following command:

cd /etc/sysconfig/network-scripts
ls ifcfg-eth1-range*

To create a brand new file, you must them in sequential numbering order. For example, if no range file previouslly exists, you should create a new one within the /etc/sysconfig/network-scripts directory by nameing it ifcfg-eth0-range0:

vi ifcfg-eth0-range0

and adding the following lines

IPADDR_START=192.168.1.100
IPADDR_START=192.168.1.110
CLONENUM_START=0

where IPADDR_START is the first IP address and IPADDR_END is the last IP address in the range. If ifcfg-eth0-range0 has been previouslly created, then you should name the next file ifcfg-eth0-range1. In order to create additional range files, they should follow the pattern of ifcfg-eth0-range0, ifcfg-eth0-range1, ifcfg-eth0-range2, ifcfg-eth0-range3, and so on.

It is important to note that CLONENUM_START represents the last IP alias of the network interface, such as eth0 in this example. It will create 10 new IP interfaces starting with eth0:0 and ending with eth0:10 for each IP address in the range. If adddding another range file such as ifcfg-eth0-range1, then you would set the CLONENUM_START to 11.

Once your range files have been created, you must restart the network service before it becomes active:

service network restart

 

Fuente: http://www.netrouting.com/blog/technical/how-do-i-add-additional-ip-addresses-in-centos/