How to add multiple IPs to a single ethernet card in CentOS from CLI

By | 21st Feb 2010 | 1 min read

When you you wish to run multiple services bound to different IPs possibly under different subnets from a single machine the simple way is to create multiple virtual adapters tied to a single physical card. The following instructions are for CentOS but should also work for RedHat and Fedora.

You will require su/sudo access for the following steps

  • Open terminal and go to /etc/sysconfig/network-scripts/
  • Run ifconfig and find the adapter that you are planning to create aliases for
  • Run cp ifcfg-eth0 ifcfg-eth0:0 for each of the new alias replacing ifcfg-eth0:0 with ifcfg-eth0:1, ifcfg-eth0:2 as needed
  • Open each of the new adapter configuration files ifcfg-eth0:0, ifcfg-eth0:1, etc, and edit DEVICE, IPADDR,NETMASK,NETWORK,BROADCASE to suit your requirements. Make sure that DEVICE is set to the new alias like eth0:0, etho0:1 etc.

Restart network service(service network restart) and you are done. :-)