Navigation

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

    List all firewall rules

    General pfSense Questions
    3
    4
    1211
    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
          • jimp
            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