-   Linux - Networking (
-   -   Mutiple Outbound Internet Connections (

Cheerz 06-25-2012 03:12 AM

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.

nini09 06-25-2012 02:43 PM

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.

All times are GMT -5. The time now is 12:25 PM.