This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Is there any way to schedule changing of PPPoE connections at a different time of day?

Good Day, 

I was wondering if there is a way to schedule a PPPoE switch/change for a specific time of day? 

I have two ISPs and we use, ISP A during the day, however they do not zero rate data between 00:00 and 06:00, ISP B does. 

I would like to automatically switch to ISP B from 00:05 to 05:55 and then automatically switch back to ISP A. 

Is this possible?

Or will I have to take a manual approach to this? I have around 800GB of data to push up, but I only have a 1Mbps upload speed, so you can see why I would like to automate this task, as it will take the better part of 6 months (gestimate) to do.

I know this is possible with IPCop, but I have all my firewall rules and internal traffic shaping setup (so the wife and the kids dont watch youtube at 1080p or destroy the first 300GB - see below reasons- with other "bandwidth intensive protocols"). So to either change to IPCop or setup it up infront of the Sophos unit in the network is not really a viable option for me.

Reasons:

ISP A - Uncapped account with a throttling policy of down to 4Mbps @ 300GB, down to 2Mbps @ 350GB and then down to after 400GB 256kbps (yup kb not KB) for the rest of the month. But it is reasonably stable and okay for our general home use, browsing, youtube, email, netflix, etc. 

ISP B is a capped 5GB account with Zero rated Data between 00:00 and 06:00, without any throttling policy. 

Hope I didn't over kill with the info.

Many thanks

Sean



This thread was automatically locked due to age.
Parents
  • Hi Sean.

    I understand this is a home license, so you are free to mod your setup. Are you familiar with using SSH and Linux? I think the only way to achieve this is using scripts and cron jobs.

    If you are willing to proceed, check https://community.sophos.com/kb/zh-cn/115120 for instructions on how to enable SSH on your UTM, in case you haven't done so already.

     

    For the script part, you would first need to obtain your PPPoE interface's ref with the command

     

    cc get_objects interface pppoe

     

    It should spit out a lot information. Look for something like:

     

    'ref' => 'REF_IntPppsXXXXXX',

     

    That is the internal reference for your PPPoEs interface. Write it down, you'll need it later. You should see two of those since you have two PPPoE interfaces, so you'll need to identify which one belongs to which ISP. After identifying what reference belongs to ISP-A you'll need a script to bring the interface down and another script to bring it up. You can use vim to create the scripts. Example:

     

    Create a script to bring down your ISP-A PPPoE interface at /usr/bin/isp-a-pppoe-down 

     

    vim /usr/bin/isp-a-pppoe-down 

     

    include this line in your script, replacing the REF_ parth with ISP-A PPPoE's ref that you collected earlier.

     

    cc change_object REF_IntPppsXXXXXX status 0

     

    save the script and quit vim with :wq. After that, make the script executable

     

    chmod +x /usr/bin/isp-a-pppoe-down 

     

    Do the same again, now for a script to bring up the PPPoE interface. Create a script at /usr/bin/isp-a-pppoe-up

     

    vim /usr/bin/isp-a-pppoe-up

     

    include this line in your script, replacing the REF_ with ISP-A PPPoE's ref that you collected earlier.

     

    cc change_object REF_IntPppsXXXXXX status 1

     

    save the script and quit vim with :wq. After that, make the script executable

     

    chmod +x /usr/bin/isp-a-pppoe-up

     

    Now you should test both scripts to make sure they do what their intended. To test, just run them on the shell while looged in into Webadmin and check if they bring your interface down and up. 

     

    Now, for the cron part, follow the general guides from BAlfson's reply on this post. In your case you would do this:

     

    vim /etc/crontab-static

     

    add those lines to your crontab

     

    5 0 * * * root /usr/bin/isp-a-pppoe-down 

    55 5 * * * root /usr/bin/isp-a-pppoe-up

     

    save and quit vim with :wq

     

    The first line would run the script and bring down the interface everyday at 00:05. The second one would run the script and bring up the interface everyday at 05:55.

    Finally, to make things stick, remember Bob's advice:

    "To force the config daemon to rewrite /etc/crontab including the new line, change one of the settings on the 'Configuration' tab in 'Management >> Up2Date', [Apply], change it back and [Apply]."

     

    That's my two cents. Maybe someone else will provide a better solution.

     Regards,

    Giovani

Reply
  • Hi Sean.

    I understand this is a home license, so you are free to mod your setup. Are you familiar with using SSH and Linux? I think the only way to achieve this is using scripts and cron jobs.

    If you are willing to proceed, check https://community.sophos.com/kb/zh-cn/115120 for instructions on how to enable SSH on your UTM, in case you haven't done so already.

     

    For the script part, you would first need to obtain your PPPoE interface's ref with the command

     

    cc get_objects interface pppoe

     

    It should spit out a lot information. Look for something like:

     

    'ref' => 'REF_IntPppsXXXXXX',

     

    That is the internal reference for your PPPoEs interface. Write it down, you'll need it later. You should see two of those since you have two PPPoE interfaces, so you'll need to identify which one belongs to which ISP. After identifying what reference belongs to ISP-A you'll need a script to bring the interface down and another script to bring it up. You can use vim to create the scripts. Example:

     

    Create a script to bring down your ISP-A PPPoE interface at /usr/bin/isp-a-pppoe-down 

     

    vim /usr/bin/isp-a-pppoe-down 

     

    include this line in your script, replacing the REF_ parth with ISP-A PPPoE's ref that you collected earlier.

     

    cc change_object REF_IntPppsXXXXXX status 0

     

    save the script and quit vim with :wq. After that, make the script executable

     

    chmod +x /usr/bin/isp-a-pppoe-down 

     

    Do the same again, now for a script to bring up the PPPoE interface. Create a script at /usr/bin/isp-a-pppoe-up

     

    vim /usr/bin/isp-a-pppoe-up

     

    include this line in your script, replacing the REF_ with ISP-A PPPoE's ref that you collected earlier.

     

    cc change_object REF_IntPppsXXXXXX status 1

     

    save the script and quit vim with :wq. After that, make the script executable

     

    chmod +x /usr/bin/isp-a-pppoe-up

     

    Now you should test both scripts to make sure they do what their intended. To test, just run them on the shell while looged in into Webadmin and check if they bring your interface down and up. 

     

    Now, for the cron part, follow the general guides from BAlfson's reply on this post. In your case you would do this:

     

    vim /etc/crontab-static

     

    add those lines to your crontab

     

    5 0 * * * root /usr/bin/isp-a-pppoe-down 

    55 5 * * * root /usr/bin/isp-a-pppoe-up

     

    save and quit vim with :wq

     

    The first line would run the script and bring down the interface everyday at 00:05. The second one would run the script and bring up the interface everyday at 05:55.

    Finally, to make things stick, remember Bob's advice:

    "To force the config daemon to rewrite /etc/crontab including the new line, change one of the settings on the 'Configuration' tab in 'Management >> Up2Date', [Apply], change it back and [Apply]."

     

    That's my two cents. Maybe someone else will provide a better solution.

     Regards,

    Giovani

Children
  • Thanks, Giovani - I just realized why one of my test scripts never ran in crontab - I'd forgotten to chmod +x it!

    It's been awhile since I tried it, but I believe I had to use /usr/local/bin/confd-client.plx instead of cc in commands executed by a cron job.  Perhaps someone can confirm that one way or the other.

    Is there a reason to not do something like the following directly in crontab-static?

    5 0 * * * root /usr/local/bin/confd-client.plx change_object REF_IntPppsXXXXXX status 0
    55 5 * * * root /usr/local/bin/confd-client.plx change_object REF_IntPppsXXXXXX status 1

    Or does using scripts allow you to use cc instead of /usr/local/bin/confd-client.plx?

    Cheers - Bob

     
    Sophos UTM Community Moderator
    Sophos Certified Architect - UTM
    Sophos Certified Engineer - XG
    Gold Solution Partner since 2005
    MediaSoft, Inc. USA
  • Hey Bob.

    Glad I could help ya. It's usually the other way around! 

    As for crontab, no reason at all. It's just my thing. I prefer to use scripts on crontab, even for one liners. I figure it makes it easier to add things up if required. But one could run the command at crontab as well, as you suggested.

    As for cc, you're right as usual. cc is an alias for /usr/local/bin/confd-client.plx, and aliases are not expanded on non-intecractive shell. Therefor, /usr/local/bin/confd-client.plx must be used, both on crontab or on a script called by crontab.

     

    Sean, I stand corrected. Please replace:

     

    cc change_object REF_IntPppsXXXXXX 

     

    for

     

    /usr/local/bin/confd-client.plx change_object REF_IntPppsXXXXXX 

     

    Regards - Giovani