After reading Stefano Rivera’s (tumbleweed) post about local only ADSL accounts I had decided to implement the idea on my home network, which has an overworked 400mhz celeron box, running debian between my router and switch doing masquerading.
I fired up my favourite terminal and started off my creating another provider script for the new IS account. I modified Stefano’s source routing script and created a script in /etc/ppp/ip-up.d/ to setup the routing accordingly.
root@hopkin:/etc/ppp/ip-up.d# cat setuprouting
#!/bin/sh
# based on tumbleweed’s split routes script
PATH=/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin
export PATH
ROUTES=/etc/routes/localroutes# Is this our internal ppp session?
if [ "$PPP_IFACE" = "ppp0" ]; then
peer=`ip addr show dev $PPP_IFACE | sed -n ‘/inet/ s#.* peer \([0-9.]*\)/.*#\1# p’`
address=`ip addr show dev $PPP_IFACE | sed -n ‘/inet/ s/.* inet \([0-9.]*\) .*/\1/ p’`ip route add “$peer” dev “$PPP_IFACE” src “$address” table 1
ip route add default via “$peer” table 1
ip rule add from “$address” table 1
fi# Is this our local ppp session?
if [ "$PPP_IFACE" = "ppp1" ]; then
cat “$ROUTES” | while read route; do
ip route add “$route” dev “$PPP_IFACE”
donepeer=`ip addr show dev $PPP_IFACE | sed -n ‘/inet/ s#.* peer \([0-9.]*\)/.*#\1# p’`
address=`ip addr show dev $PPP_IFACE | sed -n ‘/inet/ s/.* inet \([0-9.]*\) .*/\1/ p’`ip route add “$peer” dev “$PPP_IFACE” src “$address” table 1
ip route add default via “$peer” table 2
ip rule add from “$address” table 2
fi
That was it! I lie. It would of been if not for me forgetting to modify the firewall rules. So technically that was it after 3mins of pondering about the ridiculously obvious.
November 18, 2007 at 12:27 pm
Nice
Yes I helped someone else implement this on Ubuntu. A lot more straight forward then OpenWRT
November 18, 2007 at 7:53 pm
How do you make sure that ppp0 is international and ppp1 is local ?
November 19, 2007 at 9:36 am
Hey Adrian
Place “unit 0″ in the bottom of the provider file you wish to make ppp0 and “unit 1″ in the at the end of your provider file you wish to make ppp1. This forces the interface to be brought up accordingly.
June 19, 2008 at 6:04 am
Somehow i missed the point. Probably lost in translation
Anyway … nice blog to visit.
cheers, Hydrolytic.
June 19, 2008 at 6:46 pm
Hey Hydrolytic,
It’ll seem odd you don’t live in South Africa. South Africans pay an arm and a limb for international bandwidth. It only makes sense if one does more downloading from mirrors local to SA ( Such as updates, ISO’s etc ). You generally save quite a bit. It costs around R130 to get a 30GB local only ADSL account and you can then get another 1GB regular account to surf internationally for R79. Where as it’ll cost, just over R700 for a 10GB Regular ADSL when 80% of the bandwidth being used is local.