Operating System - Linux
1829556 Members
1762 Online
109992 Solutions
New Discussion

set up virtual IP in Linux

 
walter crasto_1
Frequent Advisor

set up virtual IP in Linux

Hi,
I have 2 Linux as4 severs running J2ee application.
Requirement -> set up virtual IP address so that of one j2ee instance fail then direct request to second j2ee server.

Please let me know how to accomplish above requirement.

Regards

Walter Crasto
2 REPLIES 2
Delrish
Trusted Contributor

Re: set up virtual IP in Linux

for clustering (failover/failback) of a service you need a clustering software. you can use, HP serviceguard, RedHat cluster suite or one of the opensource solutions (like openHA, Oscar,...)

Also, you can use LVS for loadbalancing between the servers. with LVS at the time of outage all the requests direct to the reamin server.
Enzo Genuardi
Advisor

Re: set up virtual IP in Linux

Hi Walter,

If you want to do it in a shell script or into a shell, and admitting that your lan interface is eth0, then just type:

ifconfig eth0:1 NewIP NETMASK 255.255.255.0 up

With this your server will answer to both IPs your original eth0 IP and the second one. If you want to disable it just do:

ifconfig eth0:1 down

If you register your "NewIP" into DNS you will have a virtual system that could be handle by any of your computer with a connection into the same part of your "NewIP" lan.

But be VERY carefully into having one and only one server activating that "NewIP".
This is the biggest part of the game and that is what clustering software are doing for you with proprietary rules that you can adapt to your needs!

Cheers,
Enzo Genuardi.