Example of enable/disable a rule based on time

Hi Guys.

Could someone give me an idea on where to start with a shell of a script?

I need one that disables a rule at 10:30am, enables it again 11am, disables again at 12:30pm, enables again and 1pm

never done a script and kind of been forced in to this. I’ve done a lot of coding/powershell, so lay it on me.

You could use a script… or an easier way would be to use 2 duplicate firewall rules that are only activated during the said times. Something like this:
/ip firewall filter
add action=accept chain=forward time=11h-12h30m,sun,mon,tue,wed,thu,fri,sat
add action=accept chain=forward time=13h-22h30m,sun,mon,tue,wed,thu,fri,sa

I would, but you actually need 3…

then if I want to block youtube, it becomes 6…

Script seems better to go to future proof it.

You could create a schedule that runs a script like this every 30 minutes. It checks the time and enables / disables the firewall rule with comment “My Comment” if the times match.
:local time [:pick [/system clock get time] 0 5]

:if ($time = “10:30”) do={
/ip firewall filter disable [find comment=“My Comment”]
}
:if ($time = “11:00”) do={
/ip firewall filter enable [find comment=“My Comment”]
}
:if ($time = “12:30”) do={
/ip firewall filter disable [find comment=“My Comment”]
}
:if ($time = “13:00”) do={
/ip firewall filter enable [find comment=“My Comment”]
}

Please tell me how to make one with the rule to work 23:00:00 - 7:00:00?
Or always have to make 2 rules, one with the 23:00:00 - 23:59:59, and the second with 00:00:00 - 7:00:00?