Differences between revisions 1 and 2
Revision 1 as of 2013-06-24 14:22:06
Size: 2135
Editor: PieterSmit
Comment: Add config details
Revision 2 as of 2013-06-24 14:22:24
Size: 2137
Editor: PieterSmit
Comment:
Deletions are marked like this. Additions are marked like this.
Line 6: Line 6:
* 2013-06 feature removed in kernel 3.6 for route caching.
  * This causes per packet load-balancing over equal cost routes, breaking ADSL links, as outside ip changes in middle of tcp session.
 * 2013-06 feature removed in kernel 3.6 for route caching.
  * This causes per packet load-balancing over equal cost routes, breaking ADSL links, as outside ip changes in middle of tcp session.

Loadbalance traffic over multiple ADSL lines

  • 2013-06 feature removed in kernel 3.6 for route caching.
    • This causes per packet load-balancing over equal cost routes, breaking ADSL links, as outside ip changes in middle of tcp session.
  • Main setup script, used in firehol.conf bash config file.
    • What it does is mark statefull sesion with exit interface and then use same interface for all other packets.
    • This works in conjunction with routing based on fw-mark.

##(c) Pieter E Smit 2013 - GPL3.
##Routing
ipt=iptables
prio=1
#Set connmark depending on dsl interface used.
for i in {1..5}; do
  int="ppp$i"
  mark="$i"
  $ipt -t mangle -I POSTROUTING 1 -o $int -m state --state NEW -j CONNMARK --set-mark $mark
  $ipt -t mangle -I PREROUTING 1 -i $int -m state --state NEW -j CONNMARK --set-mark $mark
  $ipt -t mangle -I INPUT      1 -i $int -m state --state NEW -j CONNMARK --set-mark $mark
  #Update route
  #Also done in ppp ip-up script as we cant add route if int does not exist.
  ip route replace default dev $int table $int 2> /dev/null

  ##THIS is LOCAL lan route## Update to local subnet.
  ip route replace 192.168.0.0/16 dev eth0 table $int

  #set routing rule to pick routing table depending on fwmark, table name=$int see /etc/iproute2/rt_tables
  ip rule del fwmark $mark table $int 2> /dev/null
  ip rule add fwmark $mark table $int prio $prio
  #

done
  $ipt -t mangle -I PREROUTING 1 -j CONNMARK --restore-mark

#Debug command
#   iptables -L -nv -t mangle
  • ppp/if-up and if-down script to add and remove routes as adsl go up and down.

#(c)Pieter E Smit 2013 GPL3
#adds all ppp interfaces to default route.
command="ip route replace default scope global" 
for i in `ifconfig | grep ppp | cut  -d " " -f 1` ;  do
  command="$command nexthop dev $i weight 1" ;
  #Add default route to each ppp interface's own routing table. /etc/iproute2/rt_table
  ip route replace default dev $i table $i
  done 

$command

...

linux/LoadBalanceMultipleADSLlines (last edited 2015-07-31 11:33:00 by PieterSmit)