Jumping into local Only.

November 18, 2007

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”
done

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 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.

Advertisements

5 Responses to “Jumping into local Only.”


  1. Nice πŸ™‚

    Yes I helped someone else implement this on Ubuntu. A lot more straight forward then OpenWRT πŸ™‚

  2. Adrian Says:

    How do you make sure that ppp0 is international and ppp1 is local ?

  3. igshaan Says:

    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.

  4. Hydrolytic Says:

    Somehow i missed the point. Probably lost in translation πŸ™‚ Anyway … nice blog to visit.

    cheers, Hydrolytic.

  5. igshaan Says:

    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.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: