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 5 of 14 FirstFirst 123456789 ... LastLast
Results 61 to 75 of 199

Thread: Splitting International and Local Bandwidth with IPcop

  1. #61

    Default

    Wow! This thread is growing nicely!!

    Thanks to all whom have contributed thus far to the project, I'm sure we can make the lives of our fellow ADSL users a lot easier by using theses scripts, if we can add the auto update of routes it would be perfect.

    I'm tweaking my script to do just that and trying to iron out a few issues (I'm just so busy with my normal work!!).

    Keep up the good work!!
    ADSL Status:Mweb 1Mb Uncapped. Telkom 2Mb adsl
    http://www.ptawug.co.za Free Bandwidth for all...

  2. #62
    Master
    Join Date
    Apr 2005
    Location
    Cape Town, Northern Suburbs
    Posts
    511

    Default

    It's been mentioned already, but could someone put all these scripts in a nice small app or something so the rest of us less intelligent peeps may also use it

  3. #63

    Default

    When I get my script running 100% smooth, with Auto updating Routes, I will put it into one package, for use by all, but I have so little free time at the moment!

    If any one else manages to get the auto update of routes working within their script please post it!!
    ADSL Status:Mweb 1Mb Uncapped. Telkom 2Mb adsl
    http://www.ptawug.co.za Free Bandwidth for all...

  4. #64
    Master
    Join Date
    Apr 2005
    Location
    Cape Town, Northern Suburbs
    Posts
    511

    Default

    Of course please include a short user manual or step by step guide as well please.

  5. #65

    Default

    Quote Originally Posted by ASS_SAZiN` View Post
    When I get my script running 100% smooth, with Auto updating Routes, I will put it into one package, for use by all, but I have so little free time at the moment!

    If any one else manages to get the auto update of routes working within their script please post it!!
    I am busy testing the changes to my script. I am hoping to get it all done by tomorrow eve. My job is just a bit of a hinderance at the moment

  6. #66
    Super Grandmaster hj2k_x's Avatar
    Join Date
    Jan 2006
    Location
    /\/ŻŻŻŻŻ\/\
    Posts
    29,856
    Blog Entries
    10

    Default

    A step-by-step guide for this once it works would be great

    A real break-through in the SA DSL context
    Link to me on Samsung Rewards and earn a starting bonus. http://s-rewards.co.za/linkme.html?id=F341208769
    My BTC address:15fvnAGPvomWM9dkJ7DMcVEtae3NwVMXvD

  7. #67
    Senior Member
    Join Date
    Apr 2005
    Location
    Johannesburg
    Posts
    148

    Default

    I'm using this script..... (adapted)

    Code:
    DATE=`date`
    LOGFL=/root/rt.set.log
    echo "----------------------" >> $LOGFL
    echo $DATE >> $LOGFL
    
    LOCAL=ppp1
    INTL=ppp0
    PPCHKI=`ifconfig|grep $INTL|awk '{print $1}'`
    PPCHKL=`ifconfig|grep $LOCAL|awk '{print $1}'`
    if [ "$PPCHKI" == $INTL ]; then
       if [ "$PPCHKL" == $LOCAL ]; then
          echo "$LOCAL already exists. Exiting..." >> $LOGFL
          exit
       fi 
    else
       if [ "$PPCHKL" == $LOCAL ]; then
          PID=`ps -ef|grep MyUserName|awk '{print $2}'`
          echo "NO $INTL, therfor killing $LOCAL PID $PID" >> $LOGFL
          kill -9 $PID
       fi
       echo "$INTL Not connected. Exiting..." >> $LOGFL
       exit
    fi
    
    echo "Creating connection..." >> $LOGFL
    PPUSER=local.dsl.acc
    PPASS=local.passw
    /usr/sbin/pppd plugin rp-pppoe.so eth1 usepeerdns noipdefault nodefaultroute ipcp-accept-local ipcp-accept-remote passive noccp nopcomp novjccomp user $PPUSER password $PPASS lcp-echo-interval 20 lcp-echo-failure 3 lcp-max-configure 50 maxfail 5
    sleep 15
    echo "Getting routes..."
    wget http://alm.za.net/ip/localroutes4.txt -O /tmp/localroutes
    echo "Adding routes..."
    source /tmp/localroutes 
    #   route add -net 0.0.0.0 netmask 0.0.0.0 $INTL  
    echo "Setting Intl. Route..."
    route add default dev $INTL metric 0
    # SAIX does not allow email to be sent from local only account, therfore
    # have to explicitly add the IP of smtp.saix.net to INTL route
    route add -host 196.25.240.94 $INTL
    sleep 2
    echo "Adjusting IPTABLES..."
    iptables -t nat -A POSTROUTING -o ppp+ -j MASQUERADE
    sleep 2
    echo "--- END SCRIPT ---" >> $LOGFL

    it fetches the routes and executes them.....you can run it through a grep if you are worried about executing arbitrary commands.

    I run this in my fcron every 5 mins.

    1. scp script to ipcop box
    1.5 edit script to include correct username/password
    2. set script executable
    3. edit fcron using fcrontab -e
    4. include executing the script every 5 mins
    5. check the log too see it's running
    Last edited by ArminM; 27-02-2007 at 08:44 AM. Reason: incl 1.5 ;)
    if (!preg_match("(^[-\w\.][email protected]([-a-z0-9]+\.)+[a-z]{2,4}$)i", $email)) echo "Email address $email is not valid";

  8. #68

    Default

    Quote Originally Posted by ArminM View Post
    I'm using this script..... (adapted)
    Ahhh damn you beat me to it

    I'll post my adapted script in a separate post.

  9. #69

    Default

    I followed a slightly different way of using the downloaded routes.

    The first thing I did is create a separate script for the download part (yeah I know supposed to be 1 script but this suites me better )

    My download script is as follows - called get_routes:
    Code:
    #!/bin/bash
    #Thanks to ArminM from http://mybroadband.co.za/vb/showthread.php?t=64649&page=4
    # for making this download possible.
    
    WORKDIR=$1
    LOGFILE=$WORKDIR/get_routes.log
    DATE=`date`
    echo $DATE >> $LOGFILE
    
    cd $WORKDIR
    #Backup existing route file
    mv -f $WORKDIR/localroutes4.txt $WORKDIR/localroutes4.txt.bak
    
    #Retrieve the file
    #If file already exists, do not download (-nc option), as it means 
    # creating the backup file did not work
    # Using --proxy=off option to make sure the latest version of file is
    # downloaded and not the one off  the proxy server.
    # I decided to keep appending to the wget logfile. (-a option)
    
    wget --proxy=off http://alm.za.net/ip/localroutes4.txt -nc -a $LOGFILE
    
    # Make sure download file exists after wget completed
    # If file does not exist Restore the backup
    if [ ! -f $WORKDIR/localroutes4.txt ]; then
       echo "Download failed, restoring backup" >> $LOGFILE
       mv -f $WORKDIR/localroutes4.txt.bak $WORKDIR/localroutes4.txt
    else
    #  Make sure all route commands are complete.
    #  This can't guarantee that the whole file has been downloaded
    #  but it does make sure that what has been downloaded is complete
       BCHK=`cat $WORKDIR/localroutes4.txt|grep 'route'|wc -l`
       ECHK=`cat $WORKDIR/localroutes4.txt|grep '$LOCAL'|wc -l`
       if [ $BCHK -ne $ECHK -o $BCHK -eq 0 -o $ECHK -eq 0 ]; then
          echo "Route commands incomplete, restoring backup BCHK=$BCHK ECHK=$ECHK" >> $LOGFILE
          mv -f $WORKDIR/localroutes4.txt.bak localroutes4.txt
       else
    #     In theory we now have a useful file, so I now create
    #     a "saved" version of the file for use in my rt.set script
    #     incase the localroutes4.txt file does not exist for any reason
          cp $WORKDIR/localroutes4.txt $WORKDIR/localroutes.save
       fi
    fi
    The reason I used a separate script is because at first I thought of putting it in the cron to run once a day to get the download file, regardless of what my rt.set script was doing. The rt.set script could then just use the download file that was there. On second thoughts, I thought I may aswell just call the get_route script from the rt.set script whenever a new connection was being set up. In the end that is what I did, but I have the option of putting the get_routes script in the cron if I want.

    My changed rt.set script is as follows:

    Code:
    #!/bin/bash
    
    WORKDIR='/var/log'
    DATE=`date`
    LOGFL=$WORKDIR/rt.set.log
    echo "----------------------" >> $LOGFL
    echo $DATE >> $LOGFL
    
    LOCAL=ppp1
    INTL=ppp0
    PPUSER=MyISPLocalUserName
    PPASS=MyISPLocalPassword
    PPCHKI=`ifconfig|grep $INTL|awk '{print $1}'`
    PPCHKL=`ifconfig|grep $LOCAL|awk '{print $1}'`
    if [ "$PPCHKI" == $INTL ]; then
       if [ "$PPCHKL" == $LOCAL ]; then
          echo "$LOCAL already exists. Exiting..." >> $LOGFL
          exit
       fi 
    else
       if [ "$PPCHKL" == $LOCAL ]; then
          PID=`ps -ef|grep $PPUSER|awk '{print $2}'`
          echo "NO $INTL, therfor killing $LOCAL PID $PID" >> $LOGFL
          kill -9 $PID
       fi
       echo "$INTL Not connected. Exiting..." >> $LOGFL
       exit
    fi
    
    echo "Creating connection..." >> $LOGFL
    /usr/sbin/pppd plugin rp-pppoe.so eth1 usepeerdns noipdefault nodefaultroute ipcp-accept-local ipcp-accept-remote passive noccp nopcomp novjccomp user $PPUSER password $PPASS lcp-echo-interval 20 lcp-echo-failure 3 lcp-max-configure 50 maxfail 5
    sleep 10
    
    echo "Setting up routes..."
    # Call the get_routes script
    /usr/local/bin/get_routes $WORKDIR
    
    # If the normal download file of local routes is not available for any reason,
    # then use a saved file with routes.
    # 
    if [ ! -f $WORKDIR/localroutes4.txt ]; then
       ROUTEFILE=$WORKDIR/localroutes.save
    else
       ROUTEFILE=$WORKDIR/localroutes4.txt
    fi
    for IP in `cat $ROUTEFILE|awk '{print $4}'`
    do
         route add -net $IP $LOCAL
    done
    
    echo "Setting Intl. Route..."
    route add default dev $INTL metric 0
    
    # SAIX does not allow email to be sent from local only account, therfore
    # have to explicitly add the IP of smtp.saix.net to INTL route
    route add -host 196.25.240.94 $INTL
    
    echo "Adjusting IPTABLES..."
    iptables -t nat -A POSTROUTING -o ppp+ -j MASQUERADE
    
    echo "--- END SCRIPT ---" >> $LOGFL
    Call me paranoid, but I did not want to execute any commands from a file downloaded from the internet, it may have an "rm -r *" command somewhere

    So I strip out the IP address and subnet mask and loop through the download file and set the routes myself.

    I have now put both scripts in /usr/local/bin and use /var/log for logging. You can use any directory for logging by changing the $WORKDIR variable in the rt.set script.

    I also put a couple of rudimentary checks in the scripts, to make sure the script will still run incase there is any problem downloading the file.

    Anyway, I hope the above helps.

    I am going to try and make a little install script that will take all of the above and install automatically, by passing a couple of options to the install script. If I get that working, I will post that aswell.

    Happy Internetting!!!
    Last edited by Bernie; 27-02-2007 at 02:51 PM.

  10. #70
    Master
    Join Date
    Apr 2005
    Location
    Cape Town, Northern Suburbs
    Posts
    511

    Default

    You guys are the greatest!!!

  11. #71

    Default

    Quote Originally Posted by Bernie View Post
    ....
    I am going to try and make a little install script that will take all of the above and install automatically, by passing a couple of options to the install script. If I get that working, I will post that aswell.
    For those that are interested, I created a little install package to install these scripts.

    I have put the install file on www.4shared.com. Here is the URL:

    http://www.4shared.com/dir/1869544/c...6/sharing.html

    The file is called rt-0.0.01.gz.tar

    Code:
    1. Copy the file to a temp directory on your IPcop box. You will need 
    to use WinSCP or similar program. (http://winscp.net/eng/index.php) 
    
    2. Change to this temp directory and extract the tar ball. Enter the following 
    command "tar zxvf rt-0.0.01.tar.gz"
    
    3. This will extract the files into directory called rt-0.0.01. 
    
    4. Change to directory rt-0.0.01. Please read the README file for more 
    information. Run the install script. enter "./install" 
    
    5. Follow the prompts until the install completes.
    
    *********** DISCLAIMER ************** 
    This script is distributed in the hope that it will be useful, but WITHOUT ANY
    WARRANTY; without even the implied warranty of MERCHANTABILITY or 
    FITNESS FOR A PARTICULAR PURPOSE. It comes with NO warranty or 
    guarantee, so use it at your own risk. This package adds firewall rules, 
    modifies the kernel routing table. Do NOT use this script if firewall 
    security is a major issue. 
    *********** DISCLAIMER ************** 
    If anybody does try this out, please let me if it works or does not work, what bugs there are etc. etc.

    Please read the README file before running the install.

    B.

  12. #72
    Active Member
    Join Date
    Mar 2007
    Location
    Pietermaritzburg
    Posts
    67

    Default

    Hey Bernie

    I tried your install package on as IPCop with only a green and red interface and it worked great. Thank you very much. I have been looking for a solution like this for a long time. When 'n installed it on a IPcop with blue and orange interfaces however, it didn't work. The reason for this, I figured, was because the install package assume that red is on eth1. I tried to switch my red to eth1 but still no luck. Another thing I am curious about is whether this will work together with a VPN.

    Thanks again for a great solution!

  13. #73

    Default

    Quote Originally Posted by kilkraze View Post
    Hey Bernie

    I tried your install package on as IPCop with only a green and red interface and it worked great. Thank you very much. I have been looking for a solution like this for a long time. When 'n installed it on a IPcop with blue and orange interfaces however, it didn't work. The reason for this, I figured, was because the install package assume that red is on eth1. I tried to switch my red to eth1 but still no luck. Another thing I am curious about is whether this will work together with a VPN.

    Thanks again for a great solution!
    Hi kilkraze

    Thanks for the feedback.

    You make a good point, and something I neglected to mention. I only tested on a RED-GREEN setup as that is what I have and my RED is on eth1.

    If you change the interface in the rt.set script to your RED interface that may work.
    Code:
    echo "Creating connection..." >> $LOGFL
    /usr/sbin/pppd plugin rp-pppoe.so eth1 usepeerdns....
    change eth1 in this line in the script to what ever your RED interface is on.

    Please let me know if that works, if it does, I will change the install to try and derive the RED interface instead of assuming eth1.

    As for VPN. I guess there are two ways you can look at this:

    1. Connecting to an external VPN through IPcop.
    2. IPcop hosting the VPN to give access to the resources behind IPcop.

    The first senario I use everyday, since the VPN I connect to is in SA it allways uses the local bandwidth, no problem there.

    For the second senario, I cant really comment. I have never set this up. Having said that, I cant see why this would be a problem, but I would need to test.

    If there are any other types of VPN setups I am not aware of them.

  14. #74

    Default

    Hi thanks it works great.

    But from the logs I can see that downloading of the localroutes file is failing. Doesn't say why though.

    Is there a local site I can go to to show my ipaddress so I can confirm what ip is being used locally?

    I have now thought of another nice feature that can be added.

    I want to add a third ppoe connection. One for an unshaped account for games. I thought it to work similar to the local one, but have a seperate unshapedRoutes file that I can add specific server ips to for gaming. How to add ips to it is a problem . Manually in a file is cumbersome.

    I am going to try and do it, but alas my knowledge of scripting and anything non Microsoft is lacking. So it might just take me some time but Ill post back when I've figured it out.

    If somebody else thinks the idea is worthwhile, please take a crack at it. I dont know if I've got enough braincells to get this working.

  15. #75
    Super Grandmaster Gnome's Avatar
    Join Date
    Sep 2005
    Location
    Cape Town
    Posts
    5,348

    Default

    Nice work to everyone who worked on the script!!!

    I especially like the idea of having something that can be easily install, very nice! Only one problem though, the 4shared link doesn't work: In firefox it keeps reloading the same page when I click download and in IE6 it gives me a error about my network settings being a problem.

+ Reply to Thread
Page 5 of 14 FirstFirst 123456789 ... 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
  •