Adding multiple IP addresses on CentOS
To assign more than one IP address to a CentOS server or virtual server, you can use this method.
-
Open the
rc.localfile:nano /etc/rc.local -
Add one line for each IP address you want to add (example):
/sbin/ifconfig eth0:1 192.168.1.2 netmask 255.255.255.0 /sbin/ifconfig eth0:2 192.168.1.3 netmask 255.255.255.0 /sbin/ifconfig eth0:3 192.168.1.4 netmask 255.255.255.0Note: do not add the main IP address to this list.
-
Save the file and exit.
-
Run these commands:
chmod 777 /sbin/ifconfig reboot
When the server restarts, all your IP addresses will have been added.