Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    Possible to modify rule based on a schedule?

    Scheduled Pinned Locked Moved General pfSense Questions
    2 Posts 2 Posters 262 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • J
      jeff3820
      last edited by

      Periodically I change a NAT rule to open a port. I usually remember to close the port when I am done but occasionally I forget. Is there a way, or a package, to modify a rule based on a schedule? For example, at 2:00AM, check to see if a rule is active, and if so, then deactivate the rule...otherwise do nothing.

      1 Reply Last reply Reply Quote 0
      • stephenw10S
        stephenw10 Netgate Administrator
        last edited by

        You can put a schedule on a firewall rule:
        https://docs.netgate.com/pfsense/en/latest/firewall/firewall-rule-schedules.html

        But that would require scheduling it enabled too and it doesn't sound like that would fit your usage.

        You might be able to just set the rule as disabled using a php shell command/script. Then call that from a cronjob.
        https://docs.netgate.com/pfsense/en/latest/development/using-the-php-pfsense-shell.html

        Steve

        1 Reply Last reply Reply Quote 0
        • First post
          Last post
        Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.