Wednesday, August 20, 2008

Load balancing by using Vmware and Linux

Here I will describe load balancing guide using linux with vmware workstation 6



First step is install 1 linux os(I chosed sles 10) and clone 2 more virtual machines of that machine .We will be using 1 virtual gateway and 2 virtual network members.

Then create 2 virtual switches named vmnet8 and bridged.
connect one of the gateway interface thru bridged switch-say eth1- and other to vmnet8.
Give ip address to eth1 as you connect to internet -dhcpd e.g.- and give static ip and netmask to eth0-10.0.0.2/24 e.g.Here eth0 will be our private 10.0.0.0 network's gateway and eth1 will be our wan door.When we generate http 80-or 8080- requests it should route us to the one of the internal zone member's 80.

After installation configure gateway with:

# echo net.ipv4.ip_forward = 1 >> sysctl.conf

and reload sysctl config with :

# sysctl -p
and double-check /proc/sys/net/ipv4/ip_forward it should be 1

Second step is configure our iptables nat rules.Remember we don't have to run iptables as a service if we only want iptables running our nat rules.

Here our basic nat rules:

# iptables -t nat -F // for flushing exising iptables nat rules
# iptables -t nat -I POSTROUTING -j MASQUERADE // create an postrouting masquerade
# iptables -t nat -I PREROUTING -d 136.10.195.84 -p tcp --dport 8080 -j DNAT --to 10.0.0.3:80
// finally route all packages which come from 136.10.195.84 iface(eth1) to 10.0.0.3:80 (our member 1 apache server) via our eth0 iface on the gateway

Test step; run apache server at 10.0.0.3(@ member 1) and try to load 136.10.195.84:8080 see if it's works

Registred Linux User

Registred Linux User

HitCounter