Captive Portal - Enable / Disable by Schedule or Cron



  • Hi!

    Can I Disable or Enable my captive portal by schedules or cron ?

    I need all time by captive portal, authenticated by vounchers, except 12:00 13:00 captive portal disabled.

    My captive portal is working, but i need disable/enable midday.

    Any ideas?

    Thanks



  • When you disable the portal, all traffic passes through.
    You want to implement some happy hours ?
    And what to do with the existing connections ?



  • you can create a script with

    ipfw add 10 allow ip from any to any keep-state
    

    and anotheer script with

    ipfw delete 10
    

    and use cron to launch it at specified time



  • Yess!!! It Works!!

    Here my scripts ;

    81732294-b384-4ee8-b055-12e760915253-image.png

    File: disable_captive.sh

    #!/bin/sh

    ipfw add 10 allow ip from any to any keep-state

    File: enable_captive.sh
    #!/bin/sh

    ipfw delete 10

    Now at Cron ;

    11:45 AM Captive Portal Ignored. All traffic passes through.
    13:00 PM Captive Portal Enabled, rule 10 deleted.

    981cd0f7-c66c-44a3-bf64-cf0993605764-image.png

    Tomorow I'll see if really works fine!

    Thanks @kiokoman and @Gertjan



  • sad :(

    it's not working anymore.

    Is there any other way to disable captive portal and enable it in a schedule ?



  • @Joao-Paulo said in Captive Portal - Enable / Disable by Schedule or Cron:

    sad :(

    it's not working anymore.

    More details ?
    A script that works for 2 weeks, and then stops working ....
    something has changed.



  • it didn't actually work correctly.

    I thought it was working, really, I Don't know.

    I'm turning to the forum for help.

    6b10e25c-02ba-493a-b95f-d4210df565eb-image.png


  • Rebel Alliance

    @Joao-Paulo the cron job that has been given to you actually disable the captive portal without reflecting it inside the GUI...you should check the state of the captive portal directly with ipfw command



  • @Joao-Paulo
    you need to understand what that script is doing
    IPFW is a stateful firewall used by captive portal
    it does not literally disable captive portal
    we are putting a firewall rules on top of every other rules inserted by captive portal, in this case the first rule should match and let any connection to go anywhere, so if we analazy the command

    ipfw add 10 allow ip from any to any keep-state

    we are telling ipfw to add a rules that allow any ip to go to any destination with priority 10, that should circumvent the captive portal

    this is for example:

    [2.4.4-RELEASE][root@pfSense.localdomain]/var/log: ipfw add 10 allow ip from any to any keep-state
    00010 allow ip from any to any keep-state :default
    [2.4.4-RELEASE][root@pfSense.localdomain]/var/log: ipfw list
    00010 allow ip from any to any keep-state :default
    01000 skipto tablearg ip from any to any via table(cp_ifaces)
    01100 allow ip from any to any
    02100 pipe tablearg ip from any to any MAC table(test_pipe_mac)
    02101 allow pfsync from any to any
    02102 allow carp from any to any
    02103 allow ip from any to any layer2 mac-type 0x0806,0x8035
    02104 allow ip from any to any layer2 mac-type 0x888e,0x88c7
    

    maybe the only trouble that can arise is if there is people that have used captive portal before we add that line and still have a state running, so please explain what is exactly not working


Log in to reply