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

    Developer Shell Usage and Commands

    Scheduled Pinned Locked Moved General pfSense Questions
    3 Posts 2 Posters 2.4k 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.
    • L
      louiss
      last edited by

      Hello,

      I am looking to automate a number of tasks through the developer shell such as adding/removing aliases, rules, etc. I have the basic process down and have been able to modify basic settings. Does anyone have an example of adding/modifying a firewall rule or deleting objects such as aliases or rules?

      Any help would be appreciated.

      Here is an example of what I have so far to add/modify an alias. I use this command:" ssh admin@192.168.1.1 '/usr/local/sbin/pfSsh.php' < cmds.txt " to feed the below commands to the shell so they become active. What I can't figure out is how to add a rule or delete an object.

      $config['aliases']['alias'][1] = array(
      "name" => "GoogleDNS",
      "address" => "8.8.8.8",
      "descr" => "GoogleDNS",
      "type" => "host",
      "detail" => "Added via script");

      write_config();
      exec;
      exit

      1 Reply Last reply Reply Quote 0
      • H
        heper
        last edited by

        basically you "unset" the variable and write the config again

        see how the webgui does it here:
        https://github.com/pfsense/pfsense/blob/master/src/usr/local/www/firewall_aliases.php#L134-L145

        adding&deleting fw rules can also be found in the webgui sources but are somewhat more complex
        to add/edit https://github.com/pfsense/pfsense/blob/master/src/usr/local/www/firewall_rules_edit.php  (you probably need to understand most of this file, to safely add rules)
        to delete https://github.com/pfsense/pfsense/blob/master/src/usr/local/www/firewall_rules.php#L224-L244

        1 Reply Last reply Reply Quote 0
        • L
          louiss
          last edited by

          Has anyone actually done this before and can provide an example of a rule addition from the developer shell?

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