This article will work on standard server or virtual server installations aswell.
Our XEN HVM Virtual Servers are setup for eth0 to obtain it’s primary IP address via DHCP. This is true of all our Linux configurations.
However, when you have multiple IP addresses on your virtual server, you will need to manually assign the IP address to an interface.
Here are the instructions for Ubuntu
[text]sudo vi /etc/network/interfaces[/text]
Then enter your information in the following format
[text]auto eth0:1
iface eth0:1 inet static
address 192.168.1.60
netmask 255.255.255.0
network x.x.x.x
broadcast x.x.x.x
gateway x.x.x.x[/text]
Networking will then require restarting
[text]sudo /etc/init.d/networking restart[/text]
For Centos, Fedora and other Redhat based systems
Each network interface has it’s own config file, so we need to copy an existing one for the new interface
[text]
cp /etc/sysconfig/network-scripts/ifcfg-eth0Â Â /etc/sysconfig/network-scripts/ifcfg-eth0:1
[/text]
Now we need to edit the file as required
[text]vi /etc/sysconfig/network-scripts/ifcfg-eth0[/text]
And the format should be as below, ensuring the device matches your sub interface number and there is no hardware address listed.
[text]
DEVICE=eth0:0
BOOTPROTO=static
BROADCAST=192.168.1.255
IPADDR=192.168.1.60
NETMASK=255.255.255.0
NETWORK=192.168.1.0
ONBOOT=yes
[/text]
Networking will then require a restart.
[text]/etc/init.d/networking restart[/text]
That should be it! ifconfig should new display your new interface and IP’s