Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Networking
User Name
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.


  Search this Thread
Old 10-01-2007, 05:01 AM   #1
Registered: Oct 2004
Location: Romania
Distribution: Ubuntu server, FreeBsd
Posts: 472

Rep: Reputation: 30
Load Balancing using iptables

Hi there,
I have 2 Internet connections and I want to implement the following on my linux router/firewall. It has 3 inferfaces (1xlan & 2xwan)

1. Load balancing some sort of traffic (ex http)
Web Traffic comming from the lan should balances in a round-robin fashion across wans connections.(per destination load balancing)

2. Some sort of traffic should always use one of the two connections.
Ex: icmp and tcp/ssh should always use wan1 and tcp/smtp,pop,imap should always use wan2.

O thought of something like this:

iptables -t nat -A POSTROUTING -o eth1 -p tcp --dport 22 -s -j SNAT --to-source 190.17.0.x
iptables -t nat -A POSTROUTING -o eth1 -p icmp  -s -j SNAT --to-source 192.17.0.x

iptables -t nat -A POSTROUTING -o eth0 -p tcp  -m multiport --dports 25,110,143 -s -j SNAT --to-source 89.0.x.x

echo "1" > /proc/sys/net/ipv4/ip_forward
What confuses me is that SNAT is done in POSTROUTING, this means after the routing process. How could I make the decision on what interface to send the packets based on protocol/ip/etc after the routing decision? Routing decision means choosind the outgoing interface based on some criteria (ex ip dest). right?

Please, help me understand this issue.

Many thanks


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
Need help with Dual ISP load balancing with IPTables daemonik Linux - Networking 2 12-04-2006 11:54 AM
Load Balancing Winanjaya Linux - Networking 3 10-03-2006 08:13 AM
Load Balancing without S/W hellmet Linux - Networking 2 09-28-2006 02:37 AM
Adding |Load Balancing to IPTables Firewall patpawlowski Linux - Networking 1 11-21-2005 09:42 AM
FTP with IPTables for client with load balancing Bug-bugga Linux - Security 2 10-10-2005 05:15 AM > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 10:02 PM.

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