- Now in linux Operating system lets consider a server which is connected to large environment or consider a webservers used to to host multiple information then we can give different ip address to the single Host system.
- So the Virtual IP addresss (VIP’s) allows you to use multiple ip address in single physical Network Interface…
This is very Simple to create a virtual address rather than a existing Physical Network Interface.:
So let us consider the IP address assigned and the device name as ” eth0″:
now normally when the IP is not set it will be in DHCP automatically so we need to create a physical Network Interface as mentioned above.
Now let see how to add another IP address in the same physical address eth0:0
- You must be in root access to perform these operation.
Simple way to create an virtual ip address:
Command : “ ifconfig eth0:1 inet 192.168.1.136 netmask 255.255.255.0 “
First check whether your host system Network is in DHCP (automatic IP address ) or It is in static IP, you must manually enter the ip address ,subnet mask, default gateway.
Navigation to perfrom: —->System Tab in taskbar-Administrator tab- select “Network” . you will get a pop up window.
In that you will get a Network Configuration pop up window there u will be having device as eth0, in that you must specify the Static IP address ,subnet,default gateway…if it is not available then it will be in DHCP automatic IP mode so you must not leave it in Dynamic Host…
After setting ip address you must check the ip address in terminal window by entering the command –”ifconfig ” to check the ip address is been assigned accordingly…
when you perform this and save this network information will be stored in certain directory i.e in:
navigation: “ /etc/sysconfig/network-scripts/ifcfg-eth0 “
Lets start with creating a new virtual IP address in the same host:
- First you must copy the existing etho (ethernet ) content into a new virtual ip address what you are creating
Note: “The main concept here is you must have the “physical network Interface” (the device name above metioned in the window) it must be same as eth0 i.e when you start creating a virtual ip address the physical network Interface name(device name) must be same as etho and you must start with ( : ) and enter the number accordingly for example :eth0:1, eth0:2 etc…
- command to copy the the existing eth0 contents into new virtual ip address:
There are two ways to execute the copy command (you must be in super used i.e in root access) you can just copy by navigating through the directories :
Command: “ cp /etc/sysconfig/network-scripts/ifcfg-etho /etc/sysconfig/network-scripts/ifcfg-etho:1 “
Here the content of the “etho” will be copied to the newly created “eth0:1″…
other way is to changing the directory to the network-script i.e entering into it:
Command : cd /etc/sysconfig/network-scripts and press enter.
you will enter into the network-scripts directory:
the you list the contents by using ls command:
Here the content in the directory network – script is been listed there you can find ” ifcfg-eth0″ thats the physical network interface…..
so you need to copy the contents to the newly creating ethernet device (ip address)
Command: “ cp ifcfg-eth0 ifcfg-eth0:1 “
After executing the command the cursor goes down indicating its been copied and if you check again by ls command you can able to see ifcfg-eth0:1
- now the virtual ip is set and you need to change two options in it so you can change in two ways:
- Using vi editor
- Using nano
lest Use vi editor to change:
- Command here is : vi eth0:1
after this press enter button to enter in the vi editor:
Note: simple concept in vi editor is first command : “vi filename” and when you enter into the editor you can change the contents or edit by pressing the insert key i.e ” i ” button.. and when you finish it has standard exit procedure i.e we need to say and exit so you must press esc button and : (colon) wq ,,here w-write q-quit i.e save and quit….
Here you will be having the contents which were presented in the “eth0″ default physical network interface contents..
In this we must change two things :
- DEVICE= etho:1
These two is mandatory to create a virtual ip address and the Device name …
After doing this exit the vi editor by standard procedure as mentioned above…
Now the virtual ip Address is set and stored in the corresponding directories with changes.
- The final step is to Restart the network service
After exiting the vi editor you will be back to the terminal and in there you must type the command
Command: ” service network restart “
Now the virtual Ip address is set and ready to use…
to check the ip address is set type in the command ifconfig .
Here the new virtual Ip address in the name of eth0:1 is created and the ip address is been changed to 192.168.1.136
now the host system has two ip address to use..