Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Security
User Name
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.


  Search this Thread
Old 12-22-2012, 01:31 AM   #1
Registered: Sep 2012
Posts: 125

Rep: Reputation: Disabled
Unhappy iptables load balancer

i have 2 web server behind my linux firewall box which are nated
and i want to balance load between these two web server
i have just 1 valid IP address
web1 server address is and
web2 server address is
my local firewall interface

the question is : can i use iptables with nating to balance load between these two web server by different probability ?

i have found this solution in some sites but when i run it in terminal i encounter this error :
the solution :
iptables -A PREROUTING -i eth0 -p tcp --dport 443 -m state --state NEW -m nth --counter 0 --every 3 --packet 0 -j DNAT --to-destination

the error :
iptables v1.4.12: Couldn't load match `nth':No such file or directory

i use ubuntu 11.10

if it's exist better solution to load balancing plz introduce it for me

fore give me if i have bad English language knowledge
Old 12-22-2012, 02:48 PM   #2
Registered: Jun 2009
Location: Texas
Distribution: Slackware
Posts: 611

Rep: Reputation: 219Reputation: 219Reputation: 219
I've always used 'ipvsadm' for load balancing applications.
Old 01-03-2013, 09:33 AM   #3
LQ Newbie
Registered: Nov 2009
Posts: 6

Rep: Reputation: Disabled
KEMP is free loadbalancing software that runs on linux.
This would be your best bet. NAT to an internal virtual IP and setup two backend round robin servers.
This will allow you to also do a cookie insert to keep sessions on the same server.

Also you could use round robin dns (poor mans load balancing)

and instead of setting the IP here use your round robin A record. (Unless you have to use an IP there... Not sure about that one)
iptables -A PREROUTING -i eth0 -p tcp --dport 443 -m state --state NEW -m nth --counter 0 --every 3 --packet 0 -j DNAT --to-destination

Last edited by derekmapge; 01-03-2013 at 10:52 AM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
load balancer nooralain Linux - Server 16 05-11-2012 04:47 AM
IPTables question, allow only traffic from load balancer... fxRichard Linux - Security 1 11-15-2009 12:35 PM
load balancer ? spx2 Linux - Networking 4 05-29-2007 02:00 AM
Load Balancer shane200_ Linux - Networking 1 09-16-2005 02:17 PM
Load Balancer shane200_ Mandriva 1 05-12-2005 11:59 AM > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 10:24 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration