Friday 18 January 2013

How to create virtual IP interfaces in Linux

We have this requirement , always , to simulate large number of clients using less no of resources ( Read PC or test pcs).

So we use virtual interfaces  on Linux PC to simulate this.

These are the commands to enable virtual interface and assign IP address to them

1) #cd /etc/sysconfig/network-scripts

2) create a new range file
 
# vim ifcfg-eth0-range0

CLONENUM_START=0
IPADDR_START=11.1.1.1
IPADDR_END=11.1.1.254

3) create another range file with another group of address
 
CLONENUM_START=254
IPADDR_START=11.1.2.1
IPADDR_END=11.1.2.254


4) # ifdown eth0

5) # ifup eth2

6) # ifconfig

It should show all the interface created with numbers like this.

eth0, eth0:0, eth0:1

To Remove all the virtual interface issue below command

#ifdown eth2


Internally Linux uses ifup-aliases script in /etc/sysconfig/network-scripts for crating aliases.



Happy Learning, Happy Working !!!