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

Question about Automation and firewall rules (enable/disable using SSH/API)

Scheduled Pinned Locked Moved General pfSense Questions
autmation
6 Posts 3 Posters 1.1k 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.
  • A
    AndreK
    last edited by Jan 13, 2023, 1:47 PM

    I am considering to but a pfSense appliance.
    Can my automation system SSH into the appliance and using a one-line command enable/disable a FW rule? (or more than one line)

    Can the FW do config changes using some API ? - like HTTP POST or something else?

    1 Reply Last reply Reply Quote 1
    • B
      bmeeks
      last edited by bmeeks Jan 13, 2023, 3:08 PM Jan 13, 2023, 3:07 PM

      There is no API available within pfSense for such automation.

      pfSense uses the FreeBSD pf (packet filter) firewall engine, so you can perform some operations on the ruleset using the pfctl utility with the proper command-line arguments which you could execute from a shell script.

      The official FreeBSD documentation for pfctl can be found here.

      A 1 Reply Last reply Jan 13, 2023, 5:59 PM Reply Quote 0
      • A
        AndreK @bmeeks
        last edited by Jan 13, 2023, 5:59 PM

        thank you.
        is the appliance open for SSH to shell so I can run pfctl from another device?

        B 1 Reply Last reply Jan 13, 2023, 7:09 PM Reply Quote 0
        • B
          bmeeks @AndreK
          last edited by bmeeks Jan 13, 2023, 7:10 PM Jan 13, 2023, 7:09 PM

          @andrek said in Question about Automation and firewall rules (enable/disable using SSH/API):

          thank you.
          is the appliance open for SSH to shell so I can run pfctl from another device?

          When you enable the SSD daemon via the GUI, it automatically opens the necessary port on the LAN. It does not open WAN ports that I remember. So if you needed access from offsite via SSH you would need to make arrangements. But I would never open SSH on the WAN. I would use the OpenVPN server in pfSense and create a remote VPN access client connection, and then use that to tunnel the SSH remotely. Using a "key only" access is also possible and is way more secure than a password. But a remote access VPN is the most secure in my opinion.

          By default an SSH connection will dump you to the CLI menu where you choose Option "8" to exit to a shell prompt. There are probably ways to configure the SSH process to dump you directly to the shell. Here is the official documentation: https://docs.netgate.com/pfsense/en/latest/recipes/ssh-access.html#.

          J 1 Reply Last reply Jan 13, 2023, 7:10 PM Reply Quote 0
          • J
            Jarhead @bmeeks
            last edited by Jan 13, 2023, 7:10 PM

            @bmeeks said in Question about Automation and firewall rules (enable/disable using SSH/API):

            @andrek said in Question about Automation and firewall rules (enable/disable using SSH/API):

            thank you.
            is the appliance open for SSH to shell so I can run pfctl from another device?

            When you enable the SSD daemon via the GUI, it automatically opens the necessary port on the LAN. It does not open WAN ports that I remember.

            Pretty sure it's open on all interfaces but you would need a firewall rule to allow it through the WAN. Not that I'm suggesting that.

            B 1 Reply Last reply Jan 13, 2023, 7:13 PM Reply Quote 0
            • B
              bmeeks @Jarhead
              last edited by bmeeks Jan 13, 2023, 7:13 PM Jan 13, 2023, 7:13 PM

              @jarhead said in Question about Automation and firewall rules (enable/disable using SSH/API):

              @bmeeks said in Question about Automation and firewall rules (enable/disable using SSH/API):

              @andrek said in Question about Automation and firewall rules (enable/disable using SSH/API):

              thank you.
              is the appliance open for SSH to shell so I can run pfctl from another device?

              When you enable the SSD daemon via the GUI, it automatically opens the necessary port on the LAN. It does not open WAN ports that I remember.

              Pretty sure it's open on all interfaces but you would need a firewall rule to allow it through the WAN. Not that I'm suggesting that.

              Yeah, the daemon listens on all interfaces, but the default firewall ruleset will only allow inbound traffic to connect from the LAN. The docs I linked explain that a little farther down (and refreshed my memory).

              1 Reply Last reply Reply Quote 0
              1 out of 6
              • First post
                1/6
                Last post
              Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.
                This community forum collects and processes your personal information.
                consent.not_received