Share your knowledge at the LQ Wiki.
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 06-25-2012, 03:12 AM   #1
LQ Newbie
Registered: Sep 2011
Posts: 10

Rep: Reputation: Disabled
Mutiple Outbound Internet Connections

Hi All

I need some assistance in getting my Multi WAN (Outbound internet) connections set up. Followed various articles on the internet and my configuration is included.

My scenario is as follows:

LAN Connection
eth0 -

Internet Connections using 2 ADSL lines (I just hooked up to existing connections in order for me to do some testing)

eth1 - - GW
eth2 - - GW


ip route add dev eth1 src table 1
ip route add default via table 1
ip rule add from table 1

ip route add dev eth2 src table 2
ip route add default via table 2
ip rule add from table 2

ip route replace default scope global nexthop via dev eth1 weight 1 nexthop via dev eth2 weight 1


iptables -t mangle -N WAN0
iptables -t mangle -N WAN1
iptables -t mangle -N RESTORE
iptables -t mangle -A RESTORE -j CONNMARK --restore-mark
iptables -t mangle -A WAN0 -j MARK --set-mark 1
iptables -t mangle -A WAN0 -j CONNMARK --save-mark
iptables -t mangle -A WAN1 -j MARK --set-mark 2
iptables -t mangle -A WAN1 -j CONNMARK --save-mark
iptables -t mangle -A PREROUTING -i eth0 -p tcp -m state --state ESTABLISHED,RELATED -j RESTORE
iptables -t mangle -A PREROUTING -p tcp -m state --state NEW -m statistic --mode nth --every 2 --packet 0 -j WAN0
iptables -t mangle -A PREROUTING -p tcp -m state --state NEW -m statistic --mode nth --every 2 --packet 1 -j WAN1
iptables -t nat -A POSTROUTING -o eth2 -j MASQUERADE
iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE

When doing traceroutes the traffic is leaving one of the two WAN links. Normal browsing works fine but downloads are extremely slow or time out after a while. Using the ADSL's normally from a system works fine.
Old 06-25-2012, 02:43 PM   #2
Senior Member
Registered: Apr 2009
Posts: 1,591

Rep: Reputation: 138Reputation: 138
Routing specific subnet (source ip) to a particular interface should be like this.
"ip rule add from table 1"
"ip route add table 1 dev eth4"
All traffic from will be routed using routing table 1 through eth4.


adsl, iproute2, iptables

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
Outbound http connections blocked charu Linux - Newbie 2 11-21-2010 03:04 PM
Iptables Control Outbound Connections - need help xoros Linux - Networking 5 04-29-2009 05:30 AM
Only allow outbound connections CrEsPo Linux - Security 4 01-01-2007 11:54 AM
programs making outbound connections six6 Debian 2 11-03-2004 11:04 PM
suspicious outbound connections di11rod Linux - Networking 13 01-23-2004 02:55 AM > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 05:51 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