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
Page 2 of 113 FirstFirst 1234561252102 ... LastLast
Results 16 to 30 of 1692

Thread: Splitting international and local traffic on a Linksys WRT54G

  1. #16

    Default

    The reason for using the start-up script is that it is stored in non-volatile ram, so it will survive a reboot. Everything else is lost when the router reboots, until it is recreated by the start-up script.

    You can experiment with incrasing the sleep times. I'm not currently having the same problem that you are having.

    If the routes file is missing that fact should be picked up and the file should be downloaded during the cron, which runs every 2 minutes. I have a test to check that the file is not empty, maybe that part of the script isn't working as it should. Will check later.

    Another solution would be to keep a copy of localroutes4.txt on your pc and have the script load that file instead. It may prove more reliable.

    I'm thinkng of programming an LED on the router to show when the local routing is in place. Because at the moment it is quite messy to check that all is well.

  2. #17

    Default

    Quote Originally Posted by Gatecrasher View Post
    Another solution would be to keep a copy of localroutes4.txt on your pc and have the script load that file instead. It may prove more reliable.

    I'm thinkng of programming an LED on the router to show when the local routing is in place. Because at the moment it is quite messy to check that all is well.
    I love that last idea...

    Is there any place to store the routes file elsewhere... in NVRAM? Maybe we can release our own dd-wrt image
    Just wondering in my noob mind.
    Cheers
    Last edited by mancombseepgood; 24-07-2007 at 10:21 AM.

  3. #18

    Default

    Quote Originally Posted by groundnut View Post
    Is there any place to store the routes file elsewhere... in NVRAM?
    I tired that. It's too big.

    I'm also a complete noob at this.

    I have to look everything up. Google is king.

  4. #19

    Default

    You've done an awesome job! Anyways.. if I had time, I would add a dual login and routing page to the admin screens.... For those who want to configure it with the gui - specify a file name and server to d/l the tables from or have a manual list to be edited on screen (e.g. for those with shaped and unshaped accounts for gaming / browsing). I may look at this weekend... then again, I may not - time permitting!

  5. #20

    Default

    Hey Gatecrasher... I was wondering about that LED issue to check on both routes being up...
    What about a tray app that polls the router for this info somehow... wonder how easy that would be... does the dd-wrt do FTP by default? Maybe a smb share mount on the local machine and push a small file to that share using cron on the router... then check for the presence of that file for the up or down status in the tray app. there are probably cleaner ways of doing it...

  6. #21

    Question

    Quote Originally Posted by Gatecrasher View Post
    I tired that. It's too big.

    I'm also a complete noob at this.

    I have to look everything up. Google is king.
    It compresses to 2.4kb... still too big?

  7. #22

    Default

    Quote Originally Posted by groundnut View Post
    Hey Gatecrasher... I was wondering about that LED issue to check on both routes being up...
    What about a tray app that polls the router for this info somehow... wonder how easy that would be... does the dd-wrt do FTP by default? Maybe a smb share mount on the local machine and push a small file to that share using cron on the router... then check for the presence of that file for the up or down status in the tray app. there are probably cleaner ways of doing it...
    I was thinking of something much simpler - using the LEDs on the router itself. There are are two LEDs behind the Cisco Systems logo, and most people do not use DMZ, so that LED is free too. I've written some code that will turn all these LEDs off after the default process has been killed. Then in order the amber LED indicates Local connection is up, the white LED indicates international connection is up, and finally the DMZ LED lights up when the routes are up.

    Also working on making it as fast, efficient and as bullet proof as I can.

    2.4 kb is small enough. I'm not sure, though, if binary data can be stored in nvram. I'm also not sure how to get it there.

    But I don't think accessing the routes file via http is a big issue. It should work fine if all the steps preceding occur in the correct order. Its just about bullet proofing the script.

  8. #23

    Default

    Spent way too much time on this! But it seems to be rock solid now. It makes sure everything is in place before attempting to set up routes.

    if you have two logins, amber LED is local up, white LED is intl up, dmz LED is for local routing active.

    If you have one login, only the white LED will light up.

    It no longer uses cron. It monitors the connections every 15 seconds, and restores the routing if required.

    Still a beta, so if you find problems let me know.

    Code:
    echo "#!/bin/sh
    user0=\`nvram get pppoe_username|awk '{ print \$2 }'\`
    if [ \"\$user0\" != \"\" ]; then
      # 2nd login found - split required
      while sleep 1; do
        # wait for GUI pppd to run
        guippp=\`ps|grep -c /usr/sbin/pppd\`
        if [ \$guippp -gt 1 ]; then
          # gui pppd is running
          killall pppd
          killall redial
          while sleep 1; do
            # wait for GUI pppd to die
            guippp=\`ps|grep -c /usr/sbin/pppd\` 
            if [ \$guippp -lt 2 ]; then
              # gui pppd is dead - set all leds off  
              gpio enable 2
              gpio enable 3  
              gpio enable 7  
              user1=\`nvram get pppoe_username|awk '{ print \$1 }'\` 
              pass0=\`nvram get pppoe_passwd|awk '{ print \$2 }'\`
              pass1=\`nvram get pppoe_passwd|awk '{ print \$1 }'\`
              # create local pppd on ppp0
              /usr/sbin/pppd pty '/usr/sbin/pppoe -U -I vlan1' noipdefault noauth nodefaultroute noaccomp noccp nobsdcomp nodeflate nopcomp novj novjccomp nomppe nomppc usepeerdns user \$user0 password \$pass0 default-asyncmap mtu 1492 mru 1492 persist lcp-echo-interval 5 lcp-echo-failure 10 holdoff 30 unit 0
              while sleep 1; do
                # wait for local to connect
                locppp=\`/sbin/ifconfig|grep ppp0|awk '{print \$1}'\`
                if [ \"\$locppp\" == \"ppp0\" ]; then
                  # local connected - amber led on
                  gpio disable 3
                  # create int pppd on ppp1
                  /usr/sbin/pppd pty '/usr/sbin/pppoe -U -I vlan1' noipdefault noauth defaultroute noaccomp noccp nobsdcomp nodeflate nopcomp novj novjccomp nomppe nomppc usepeerdns user \$user1 password \$pass1 default-asyncmap mtu 1492 mru 1492 persist lcp-echo-interval 5 lcp-echo-failure 10 holdoff 30 unit 1
                  while sleep 1; do
                    # main monitoring/processing loop 
                    intppp=\`/sbin/ifconfig|grep ppp1|awk '{print \$1}'\`
                    if [ \"\$intppp\" == \"ppp1\" ]; then
                      # int connected - white led on
                      gpio disable 2
                      locppp=\`/sbin/ifconfig|grep ppp0|awk '{print \$1}'\`
                      if [ \"\$locppp\" == \"ppp0\" ]; then
                        # local connected
                        gpio disable 3
                        isrouted=\`/sbin/route -n|grep '196.26.0.0'|awk '{print \$8}'\`  
                        if [ \"\$isrouted\" == \"ppp0\" ]; then
                          # local is routed - dmz led on
                          gpio disable 7
                          # all is well so sleep longer
                          sleep 14
                        else
                          # local is not routed
                          gpio enable 7
                          # set default route 
                          /sbin/route add default dev ppp1 metric 0
                          /sbin/route del default dev ppp0 metric 0
                          sleep 2
                          if [ -f /tmp/localroutes4.txt ]; then
                            # route file exists 
                            isfound=\`cat /tmp/localroutes4.txt|grep '196.26.0.0/16'|awk '{print \$1}'\`
                            if [ \"\$isfound\" == \"route\" ]; then
                              # route file is valid - set routes
                              for IP in \`cat /tmp/localroutes4.txt | awk '{print \$4}'\`; do
                                 /sbin/route add -net \$IP ppp0
                              done
                              # add SAIX mail and news to intl
                              /sbin/route add -host 196.25.240.94 ppp1
                              /sbin/route add -host 196.43.2.61 ppp1
                              sleep 2
                              # reset default routes 
                              /sbin/route add default dev ppp1 metric 0
                              /sbin/route del default dev ppp0 metric 0
                              sleep 2
                              # set maquerading 
                              /usr/sbin/iptables -t nat -A POSTROUTING -o ppp+ -j MASQUERADE
                              sleep 2
                              gpio disable 7
                            else
                              # route file invalid/empty - fetch   
                              /usr/bin/wget http://alm.za.net/ip/localroutes4.txt -O /tmp/localroutes4.txt
                            fi
                          else
                            # route file not found - fetch 
                            /usr/bin/wget http://alm.za.net/ip/localroutes4.txt -O /tmp/localroutes4.txt   
                          fi
                        fi
                      else
                        # local disconnected 
                        gpio enable 3
                        gpio enable 7
                      fi
                    else
                      # int disconnected 
                      gpio enable 2 
                    fi
                  done    
                fi         
              done 
            fi 
          done
        fi
      done
    else
      # split not required
      while sleep 1; do
        # process loop
        intppp=\`/sbin/ifconfig|grep ppp0|awk '{print \$1}'\`
        if [ \"\$intppp\" == \"ppp0\" ]; then
          # int connected - white led on
          gpio enable 3
          gpio disable 2
          # all is well so sleep longer
          sleep 14         
        else
          # int disconnected - leds off
          gpio enable 3
          gpio enable 2 
        fi
      done
    fi" > /tmp/splitter
    chmod +x /tmp/splitter
    /tmp/splitter &
    Requirements:
    Linksys WRT54G/GS/GL v3.0+ (LED control may not work on earlier versions)
    Latest stable DD-WRT firmware
    1 international and 1 local ADSL account.

    Instructions:
    1. Paste above code into DD-WRT GUI - Administration - Commands. Click "Save Startup"
    2. Go to SetUp - Basic SetUp and make sure your connection type is PPPoE
    3. Set connection strategy to keep alive - redial 30
    4. Enable RP PPPoE
    5. To split international and local, enter both usernames separated by a space in the user name field ie: [[email protected] [email protected]]
    6. Do the same the with the passwords (it helps to unmask while editing). Make sure you enter international first, local second.
    7. Click "Save Settings". The router will reboot.

    To remove the script at anytime, clear the command box and click "Save Startup" and then "Reboot Router" form the Administration - Management screen.

    Hope this is it. Need to get my life back.

    EDIT: The script has been updated to fix zombie process problem.
    29/7: The script routes SAIX smtp and news servers to the international account.
    Last edited by Gatecrasher; 29-07-2007 at 02:09 PM. Reason: Updating script

  9. #24

    Default

    Lol - shotto Gatecrasher
    I will test and let you know!

    What I was thinking was adding a message to the status page (which can be viewed without loggin in to the router) that says ppp1 up/down and ppp2 up/down, then a tray app that polls that page and shows the status of ppp1 and 2... Useful for folk not in the same room as the router. Just not sure how to incorporate that into the web gui - have to rebuild the .bin... I'll take a look.

    BTW - excellent work on the script!
    Last edited by mancombseepgood; 25-07-2007 at 07:57 AM.

  10. #25

    Default Will this work on the Micro Version of DD-WRT

    Hi Gatecrasher

    Thanks for the awesome project, you are helping loads of people out with this

    I have a WRT54G V5 which I have reflashed with the Micro edition of DD-WRT. Do you know if the Micro version has all the modules necessary to get the traffic routing to work on it?

    Thanks

    JohnB

  11. #26

    Default

    Quote Originally Posted by Kooku View Post
    Hi Gatecrasher

    Thanks for the awesome project, you are helping loads of people out with this

    I have a WRT54G V5 which I have reflashed with the Micro edition of DD-WRT. Do you know if the Micro version has all the modules necessary to get the traffic routing to work on it?

    Thanks

    JohnB
    Just interested - what's the benefit of running the micro version?

  12. #27

    Default

    Quote Originally Posted by Kooku View Post
    I have a WRT54G V5 which I have reflashed with the Micro edition of DD-WRT. Do you know if the Micro version has all the modules necessary to get the traffic routing to work on it?
    Judging by This I would expect it to work on v5 and v6. All the requirements appear to be present. The only doubtful module might be rp-pppoe. But you should be able to see whether it is available on the GUI setup page.

    BTW: I've run into a snag on my last script. It seems to produce ever increasing numbers of zombie processes on the router, which eventually requires a reboot after about 24 hours. It also effects upnp. This is probably due to the script running permanently rather than from the cron - perhaps it is preventing regular maintenance tasks to run.

    I've written a fix, but haven't tested it yet. Hopefully I will have an update tonight.
    Last edited by Gatecrasher; 26-07-2007 at 03:00 PM.

  13. #28

    Default

    Quote Originally Posted by groundnut View Post
    Just interested - what's the benefit of running the micro version?
    Its is more of a requirement than a benefit. Version 5 & 6 of the router have much less memory than earlier versions.

  14. #29

    Default

    Quote Originally Posted by Gatecrasher View Post
    Judging by This I would expect it to work on v5 and v6. All the requirements appear to be present. The only doubtful module might be rp-pppoe. But you should be able to see whether it is available on the GUI setup page.

    BTW: I've run into a snag on my last script. It seems to produce ever increasing numbers of zombie processes on the router, which eventually requires a reboot after about 24 hours. It also effects upnp. This is probably due to the script running permanently rather than from the cron - perhaps it is preventing regular maintenance tasks to run.

    I've written a fix, but haven't tested it yet. Hopefully I will have an update tonight.
    Hi, I noticed a hang at one point yesterday, but otherwise it works like a bomb. I will reset it from time to time - no harm done. Thanks!

  15. #30

    Default

    Quote Originally Posted by Gatecrasher View Post
    Its is more of a requirement than a benefit. Version 5 & 6 of the router have much less memory than earlier versions.
    Aah - I see mine says it has 13Mb of 16mb available...

+ Reply to Thread
Page 2 of 113 FirstFirst 1234561252102 ... LastLast

Tags for this Thread

Bookmarks

Bookmarks

Posting Permissions

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