Re: Starting from scratch w/ multiple uplinks

Linux Advanced Routing and Traffic Control

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Am Dienstag, 10. Mai 2005 14:56 schrieb Markus Schulz:
> Am Dienstag, 10. Mai 2005 09:33 schrieb Rafael A Barrero:
> > Thanks for the link!
> >
> > At the beginning of the document it states that it will not work
> > with two modem connections. What if both my ADSL lines are pppoe?
> > Will this still work?
>
> it works fine. if i'm at home i can post my script.

okay, here is the important part of my script:

#!/bin/sh
set -x
PTP=`ifconfig ppp0 | grep P-t-P | sed 's/.*P-t-P:\([^ ]*\).*/\1/g'`
IP1=`ifconfig ppp0 | grep addr | sed 's/.*addr:\([^ ]*\).*/\1/g'`
IP2=`ifconfig ppp1 | grep addr | sed 's/.*addr:\([^ ]*\).*/\1/g'`

echo 1 >  /proc/sys/net/ipv4/ip_forward

#del all routes from table 201 (search for better way to do this)
for route in `ip rule list | grep ^201 | sed 's/^201:.*from \([^ ]*\) 
lookup 201/\1/'`; do
        ip rule del prio 201 from $route table 201
done

#del all routes from table 202 (search for better way to do this)
for route in `ip rule list | grep ^202 | sed 's/^202:.*from \([^ ]*\) 
lookup 202/\1/'`; do
        ip rule del prio 202 from $route table 202
done

ip rule del prio 50 table main
ip rule add prio 50 table main
ip route del default table main

#ppp0
ip rule add prio 201 from $IP1 table 201

#next two lines is for testing purpose
ip rule del fwmark 0x20 table 201
ip rule add fwmark 0x20 table 201

ip route add default via $PTP dev ppp0 src $IP1 proto static table 201
ip route append prohibit default table 201 metric 1 proto static

#ppp1
ip rule add prio 202 from $IP2 table 202
ip route add default via $PTP dev ppp1 src $IP2 proto static table 202
ip route append prohibit default table 202 metric 1 proto static

#multipath route.
ip rule del prio 222 table 222
ip rule add prio 222 table 222
ip route add default table 222 proto static \
        nexthop via $PTP dev ppp0 \
        nexthop via $PTP dev ppp1


#skipped all other firewall iptables rules except the two needed snat 
iptables -t nat -P POSTROUTING ACCEPT
iptables -t nat -I POSTROUTING -o ppp0 -j SNAT --to-source $IP1
iptables -t nat -I POSTROUTING -o ppp1 -j SNAT --to-source $IP2


if you have some improvements, then let me a note.

-- 
Markus Schulz
_______________________________________________
LARTC mailing list
LARTC@xxxxxxxxxxxxxxx
http://mailman.ds9a.nl/cgi-bin/mailman/listinfo/lartc

[Index of Archives]     [LARTC Home Page]     [Netfilter]     [Netfilter Development]     [Network Development]     [Bugtraq]     [GCC Help]     [Yosemite News]     [Linux Kernel]     [Fedora Users]
  Powered by Linux