Environment: Linux 2.6.32-220.23.1.el6.x86_64 #1
It is possible to assign more than one IP address to one physical interface.
Why would you want to do this? There may be several reasons for wanting additional IP addresses on one card, in my case I want to fire up an additional instance of Jboss but to do this I need to bind to a unique IP address. In linux (in this example its centos) its simple, follow these steps:
First run an ipconfig to see what you have configured:
> ifconfig
eth0 Link encap:Ethernet HWaddr 00:50:56:87:00:1E
inet addr:192.168.57.54 Bcast:192.168.57.255 Mask:255.255.255.0
inet6 addr: fe80::250:56ff:fe87:1e/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:186158343 errors:0 dropped:0 overruns:0 frame:0
TX packets:586031577 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:41119255272 (38.2 GiB) TX bytes:814282374844 (758.3 GiB)
You can this interface is assigned the IP address of 192.168.57.54, next we need to edit a file so cd to /etc/sysconfig/network-scripts (this may be slightly different depending on your flavour of linux).
> cd /etc/sysconfig/network-scripts
In this folder you will find the config files for the interfaces, we are interested in the interface eth0 so we need to create a new file called ifcfg-eth0:1 (or ifcfg-eth0\:1) and add the following:
DEVICE=eth0:1
NM_CONTROLLED=yes
ONBOOT=yes
HWADDR=00:50:56:87:00:1e
TYPE=Ethernet
BOOTPROTO=none
IPADDR=192.168.57.55
PREFIX=24
GATEWAY=192.168.57.254
DNS1=192.168.57.11
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="System eth0:1"
DNS2=192.168.57.12
USERCTL=no
Notice the hardware address is the same as eth0 interface but the IP address is not, this IP address will be our new IP address but uses the same interface…
To enable the new IP address bring it up with ifup and the run an ifconfig to see the new settings, hopefully will look something like this:
> ifup eth0:1
> ifconfig
eth0 Link encap:Ethernet HWaddr 00:50:56:87:00:1E
inet addr:192.168.57.54 Bcast:192.168.57.255 Mask:255.255.255.0
inet6 addr: fe80::250:56ff:fe87:1e/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:186162124 errors:0 dropped:0 overruns:0 frame:0
TX packets:586035365 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:41119647929 (38.2 GiB) TX bytes:814285419799 (758.3 GiB)
eth0:1 Link encap:Ethernet HWaddr 00:50:56:87:00:1E
inet addr:192.168.57.55 Bcast:192.168.57.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1