Join us now. It is free, and it takes less than 1 minute to register.
Register now
Subscribe to our daily newsletter. It is free, and it comes with many benefits.

+ Reply to Thread
Results 1 to 15 of 1692

Thread: Splitting international and local traffic on a Linksys WRT54G

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Super Grandmaster
    Join Date
    Jan 2005
    0 Post(s)
    0 Thread(s)

    Cool Splitting international and local traffic with DD-WRT

    Had to abandon Route Sentry. It was running on my machine with DDProxy which was acting as a proxy for my home network.

    It did the basic stuff fine, but email (with large attachments), ftp, and most web based apps that required open ports on the firewall caused endless hassles. There was also the drawback of the internet going down whenever I rebooted or switched off my pc.

    Looking for an alternative I figured I would rather set up traffic splitting with IPCOP on an old PC. But unfortunately (or fortunately) after putting an old box together I found that the graphics card was shot.

    Having read this thread though I twigged that my Linksys WRT54GS router also runs under linux and the broad methodology in the thread could possibly be applied to the router.

    Many thanks to contributers of the IPcop thread and particularly Bernie for the scripts and ArminM for providing the local routes.

    So after endless messing about with the script it finally works. And is totally transparent to the entire network. With minimum maintenance too. Heaven, really.

    I have a Linksys WRT54GS v4 with HyperWRT Thibor 15c firmware. The firmware allows for a non-volatile startup script. Very handy for the job in hand. I use this script to create another executable script in the volatile /tmp folder on boot up. This script runs every two minutes to check that the local pppoe connection is running. If necessary it will connect the local connection and create the necessary routing table entries.

    Just set the router to dial a pppoe connection to your international account. Go to the routers Web GUI under Administration, Management. Edit Start Up Script. Then paste and copy the following script into the editor. Edit the username and password for your local account. Save the script. Reboot. And after several minutes you'll be enjoying a more cost effective internet experience.

    That's all there is too it, really.

    If you are using a later version of the WRT54G/S you may struggle getting 3rd party firmware to work. If you are using different firmware the script may still be useful to you, but program paths will possibly require editing.

    I particularly like the HyperWRT Thibor firmware because it is incredibly clean and stable. My router can run for months without a reboot.

    Here is the script. Remember to provide your MyUserName and MyPassWord for your local only account.

    echo "INTS=`/sbin/ifconfig|grep ppp0|awk '{print $1}'`
       echo "INTS=" >> /tmp/splitlog 
          LOCS=`/sbin/ifconfig|grep ppp1|awk '{print $1}'`
       echo "LOCS=" >> /tmp/splitlog
    if [ "" == "ppp0" ]; then
       if [ "" != "ppp1" ]; then
         /usr/sbin/pppd pty '/usr/sbin/pppoecd vlan1 -u MyUserName -p MyPassWord -i 0 -I 30 -T 5 -t 1492 -k' noipdefault nodefaultroute ipcp-accept-local ipcp-accept-remote passive noccp nopcomp novjccomp lcp-echo-interval 20 lcp-echo-failure 3 lcp-max-configure 50 maxfail 5
         sleep 15
         LOCUP=`/sbin/ifconfig|grep ppp1|awk '{print $1}'`
          if [ "" == "ppp1" ]; then
             echo "Local connect succeeded. Routing..." >> /tmp/splitlog
             /usr/bin/wget -O /tmp/localroutes4.txt
             for IP in `cat /tmp/localroutes4.txt | awk '{print $4}'`
                 /sbin/route add -net  ppp1
             /sbin/route add default dev ppp0 metric 0
             sleep 2
             /usr/sbin/iptables -t nat -A POSTROUTING -o ppp+ -j MASQUERADE
             sleep 2
             echo "Local connect failed" >> /tmp/splitlog
    fi" > /tmp/splitter
    chmod +x /tmp/splitter
    echo "*/2 * * * * root /tmp/splitter" > /tmp/cron.d/check_split
    I'm a complete Linux noob. The code could certainly be improved and made more robust, so feel free.

    However, I take no responsibility for your actions. Don't pin any bricked routers on me.

    The following commands can be run in Hyperwrt's Web GUI "Run Command" screen (or I guess you could do the same via telnet/putty etc):

    ifconfig {will show whether ppp0 (International) and ppp1 (Local) are connected and the amount of traffic that they have each generated since connecting.}

    route -n {will show the routing table. If the script is working there should be a large number of entries directing traffic to ppp1.}

    cat /tmp/splitlog {debugging generated by the script - at some point best to remove debugging from the script. Memory is capped, ie not unlimited.}

    cat /tmp/localroutes4.txt {shows the downloaded routing table}

    That's it. Have fun.

    EDIT: Due to the unreliability of HyperWrt's pppoecd connections, I have since changed firmware to use rp-pppoe under DD-WRT. Script has been revised in later posts. Latest Version is here
    Last edited by Gatecrasher; 17-07-2009 at 10:03 AM. Reason: Updating Link to latest script

+ Reply to Thread

Tags for this Thread



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts