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.

  1. Open the rc.local file:

    nano /etc/rc.local
    
  2. 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.0
    

    Note: do not add the main IP address to this list.

  3. Save the file and exit.

  4. Run these commands:

    chmod 777 /sbin/ifconfig
    reboot
    

When the server restarts, all your IP addresses will have been added.

Was this article helpful?