You may need to setup several ip addresses to be served by the same physical network interface. You may need to setup few (secondary) IP addresses to be served by same virtual network interface. For example If you are using Apache server very useful for setting up multiple virtual sites for a single network interface with different IP addresses.
The below instruciton for all Linux distributions like CentOS, RHEL, Fedora,...
Create Virtual Interface:
Default interface name is "ifcfg-eth0" this is located in /etc/sysconfig/network-scripts, create interfaces for to accomplish many ip addresses. This post describes configure 2 IP addresses.
# ls
ifcfg-eth0 ifdown-bnep ifdown-isdn ifdown-sit ifup-bnep ifup-isdn ifup-ppp ifup-wireless
ifcfg-lo ifdown-eth ifdown-post ifdown-tunnel ifup-eth ifup-plip ifup-routes init.ipv6-global
netowrk-functions ifdown-ippp ifdown-ppp ifup ifup-ippp ifup-plusb ifup-sit net.hotplug
ifdown ifdown-ipv6 ifdown-routes ifup-aliases ifup-ipv6 ifup-post ifup-tunnel network-functions-ipv6
Assume that the below interfaces assigning IP addresses,
ifcfg-eth0:0 = 192.168.0.210
ifcfg-eth0:1 = 192.168.0.211
TYPE=Ethernet
DEVICE=eth0
IPADDR=192.168.0.110
NETMASK=255.255.255.0
BROADCAST=192.168.0.255
NETWORK=192.168.0.200
ONBOOT=yes
GATEWAY=192.168.0.1
Now, copy the configure file,
# cp ifcfg-eth0 ifcfg-eth0:1
Configure Interface:
Now, open the configure file everyone and update the parameters,
TYPE=Ethernet
DEVICE=eth0:0
IPADDR=192.168.0.210
NETMASK=255.255.255.0
BROADCAST=192.168.0.255
NETWORK=192.168.0.200
ONBOOT=yes
GATEWAY=192.168.0.1
TYPE=Ethernet
DEVICE=eth0:1
IPADDR=192.168.0.211
NETMASK=255.255.255.0
BROADCAST=192.168.0.255
NETWORK=192.168.0.200
ONBOOT=yes
GATEWAY=192.168.0.1
Once you have verified all the changes restart your network service,
# ifconfig
eth0 Link encap:Ethernet HWaddr 50:b7:c3:5a:1e:6e
inet addr:192.168.0.110 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::52b7:c3ff:fe5a:1e6e/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:56702 errors:0 dropped:0 overruns:0 frame:0
TX packets:34554 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:34300113 (34.3 MB) TX bytes:5643764 (5.6 MB)
eth0:0 Link encap:Ethernet HWaddr 01:26:EE:C3:52:C3
inet addr:192.168.0.210 Bcast:1192.168.0.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Interrupt:11
eth0:1 Link encap:Ethernet HWaddr 14:CC:EE:A1:12:A2
inet addr:192.168.0.211 Bcast:1192.168.0.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Interrupt:11
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:1081128 errors:0 dropped:0 overruns:0 frame:0
TX packets:1081128 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1656298983 (1.5 GiB) TX bytes:1656298983 (1.5 GiB)
Also ping the both IP address, 192.168.0.210, 192.168.0.211.
its very usefull.. thanks