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

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. :-)

Comments

#this command will do not

#this command will do not permanent

ifconfig eth0:1 192.168.56.70

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options