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- e.g.Here eth0 will be our private 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 -p tcp --dport 8080 -j DNAT --to
// finally route all packages which come from iface(eth1) to (our member 1 apache server) via our eth0 iface on the gateway

Test step; run apache server at member 1) and try to load see if it's works

1 comment:

Maire said...

Well written article.

Registred Linux User

Registred Linux User