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

    List all firewall rules

    Scheduled Pinned Locked Moved General pfSense Questions
    4 Posts 3 Posters 1.5k 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.
    • ?
      Guest
      last edited by

      Hi all,
      I want to wite a php cli script to show all firewall rules.
      the following code doesn't print anything. I have 3 rules.
      can you help me?

      
      $a_filter = &$config['filter']['rule'];
      
      for ($i = 0; $i < count($a_filter); $i++) {
      printf("num:%d", $i);
      
      }
      
      
      1 Reply Last reply Reply Quote 0
      • W
        wallabybob
        last edited by

        How do you invoke the script?

        How does $config get initialised?

        1 Reply Last reply Reply Quote 0
        • ?
          Guest
          last edited by

          Thank you
          My initialization was incorrect.

          1 Reply Last reply Reply Quote 0
          • jimpJ
            jimp Rebel Alliance Developer Netgate
            last edited by

            #!/usr/local/bin/php -q
            require_once('config.inc');
            global $config;
            $a_filter = &$config['filter']['rule'];
            
            for ($i = 0; $i < count($a_filter); $i++) {
            printf("num:%d", $i);
            
            }
            ?>
            

            …

            : ./test.php 
            num:0num:1num:2num:3num:4num:5num:6num:7num:8
            

            Remember: Upvote with the 👍 button for any user/post you find to be helpful, informative, or deserving of recognition!

            Need help fast? Netgate Global Support!

            Do not Chat/PM for help!

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