How do I add a second Elastic IP address to an elastic network interface attached to my EC2 instance running CentOS 6 or RHEL 6?
How do I add a second Elastic IP address to an elastic network interface attached to my Amazon Elastic Compute Cloud (Amazon EC2) instance running CentOS 6 or RHEL 6 and have it persist during bootup?
"How do I add a second Elastic IP address to an elastic network interface attached to my Amazon Elastic Compute Cloud (Amazon EC2) instance running CentOS 6 or RHEL 6 and have it persist during bootup?Short descriptionWhen you add a second Elastic IP address to an elastic network interface, that Elastic IP address is lost when you reboot the interface. To make the second Elastic IP address persist during the reboot, you must create a second interface configuration file (ICF).ICFs control the software interfaces for individual network devices. The system uses these files as it boots to determine what interfaces to bring up and how to configure them.The default ICF is /etc/sysconfig/network-scripts/ifcfg-eth0. When two Elastic IP addresses exist on a single interface, the second Elastic IP address becomes ":1"—that is, /etc/sysconfig/network-scripts/ifcfg-eth0:1.ResolutionCreate a second interface configuration file1.    Attach two Elastic IP addresses to the elastic network interface from the Amazon EC2 console. For more information, see Multiple IP addresses.2.    Use the touch command to create the ifcfg-eth0:1 file for the second Elastic IP address in the /etc/sysconfig/network-scripts/ directory:$ sudo touch /etc/sysconfig/network-scripts/ifcfg-eth0:13.    Add the following parameters to the ifcfg-eth0:1 file:DEVICE=eth0:1BOOTPROTO=staticNETMASK=255.255.255.0ONBOOT=yesTYPE=EthernetIPADDR=172.31.34.195Note: IPADDR uses the private IP address associated with the second Elastic IP address you associated with the interface. After you select your instance, you can find the private IP address in the Amazon EC2 console under Secondary private IPs.Change the context of the second ICF to match the default ICF1.    To view the security context of the ifcfg-eth0:1 file, use the –Z option with the ls command:$ ls -Z ifcfg-eth*2.    Change the user to system_u using the –u option with the chcon command:$ sudo chcon -u system_u ifcfg-eth0:13.    Change the type to net_conf_t using the –t option with the chcon command:$ sudo chcon -t net_conf_t ifcfg-eth0:14.    Compare the two files by running the following command:$ ls -Z ifcfg-eth0*-rw-r--r--. root root system_u:object_r:net_conf_t:s0  ifcfg-eth0-rw-r--r--. root root system_u:object_r:net_conf_t:s0  ifcfg-eth0:1Bring up the interface1.    Bring up the second interface by running the ifup command:$ sudo ifup eth0:12.    If there are issues with the second ICF, run the ethtool command to verify detection of the second ICF:$ ethtool eth0:1The output appears similar to the following:Settings for eth0:1:Link detected: yesIf the output isn't as expected, run the ifup command and verify that the second interface is present. Then, review the ICF file to be sure that it is correct, and reload it.Reboot the instanceReboot your instance by running the reboot command.Related informationElastic IP addressesElastic network interfacesFollow"