Forum Discussion

sjko_254603's avatar
sjko_254603
Icon for Nimbostratus rankNimbostratus
May 12, 2017

Apply Filter time setting

Hi

 

Please let me know if there is an I-Rule or other method that can apply filter policy through time setting.

 

Thank you.

 

3 Replies

  • The following irule will deny connection out of business hours. you can filter source / destination / ports in this irule.

    when RULE_INIT {
        array set static::timerange {
            Sunday {"05:30" "16:00"}
            Monday {"05:30" "16:00"}
            Tuesday {"05:30" "16:00"}
            Wednesday {"05:30" "16:00"}
            Thursday {"05:30" "16:00"}
            Friday {}
            Saturday {}
        }
    }
    
    when CLIENT_ACCEPTED {
        set now [clock seconds]
        set current_day [clock format $now -format {%A}]
        set start [lindex $static::timerange($current_day) 0]
        set end [lindex $static::timerange($current_day) 1]
        if {($start ne "") && ($end ne "") && ($now >= [clock scan $start]) && ($now < [clock scan $end])} {
            do nothing
        } else {drop}
        unset start end
    }
    

    it is not possible to manage packet filter in irule. if you have AFM, you can manage irules in AFM rule.