All dedicated and virtual private servers come with 2 IP addresses by default. The main IP address has already been assigned to your server to allow you access for administration and management. You can use your secondary IP address to run a specific service separate from your main IP, such as SMTP or an SSL certificate. Before you can configure services on your additional IP address, you will need to bind the IP address to your network interface card and enable the IP address in your myCP under Enable / Disable IPs.
In this example, we will create a virtual interface to house an additional IP address—the advantage being that only one physical NIC is required. The network configuration scripts are located in /etc/sysconfig/network-scripts/ so we will navigate to that directory by typing the following command.
Notice the two files, ifcfg-eth0 and ifcfg-eth1. These files represent the interfaces for the primary and secondary network adapters respectively. If a third NIC was present, then there would be an ifcfg-eth2 file. For the purposes of this example, we will restrict our attention to the primary network interface, eth0. Let’s proceed with binding an additional IP address, say 22.214.171.124 as an example; of course, you will enter the IP address that you wish to bind. Back to the example, this particular IP address has a subnet mask of 255.255.248.0 and a default gateway of 126.96.36.199. If you do not have the subnet mask and default gateway for your additional IP address, please contact technical support for assistance.
Now we can proceed to add the alias file for our additional IP address. Typically the first alias is generated by appending a 0 to the interface file to which you are binding the IP address. In this case, we are dealing with ifcfg-eth0. If we wanted to add more than one IP address, simply append a 1, then a 2, and so on consecutively for the additional IPs. We begin by making a copy of the primary network interface script.
cp ifcfg-eth0 ifcfg-eth0:0
Now we must edit the ifcfg-eth0:0 file to change the device name, IP address, subnet mask, and default gateway. First take a look at the contents of the file to see what needs to be changed.
The lines that need to be edited begin with DEVICE, NETMASK, IPADDR, and GATEWAY. Open the ifcfg-eth0:0 file in your favorite text editor (this example will use vi) and change the device name to eth0:0 (note the number after the colon may differ if you already have one or more additional IP addresses bound). Lastly, enter your netmask, IP address, and gateway and save the file.
Once the changes have been made, verify the contents are entered correctly.
If all is well, you can now activate the additional IP by typing
To verify that the alias has come online successfully, you can type
and look for the new alias in the list of active IPs. Remember to enable the IP address in your myCP if you have not already done so.