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

    Create firewall rules by script

    Firewalling
    4
    5
    790
    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.
    • R
      Roberto Bianchi
      last edited by

      Hi to all,
      I saw previous topic but I would like to know if with new version I can add rules from external application.
      I woluld like to create a firewall rules that my SIEM known like an attack.

      Can I do that?
      Thanks
      Roberto

      1 Reply Last reply Reply Quote 0
      • NogBadTheBadN
        NogBadTheBad
        last edited by

        Wouldn't you be better installing something like Snort or Suricata and sign up to a paid subscription?

        Andy

        1 x Netgate SG-4860 - 3 x Linksys LGS308P - 1 x Aruba InstantOn AP22

        1 Reply Last reply Reply Quote 0
        • R
          Roberto Bianchi
          last edited by

          Hi,
          i have an IDS/IPS system but I wuold like to do this by SIEM and PFsense if it possible.

          Thanks

          K 1 Reply Last reply Reply Quote 0
          • K
            Konstanti @Roberto Bianchi
            last edited by Konstanti

            @Roberto-Bianchi
            Hello
            To dynamically add / remove rules to the firewall you need to use anchors

            https://www.openbsd.org/faq/pf/anchors.html

            PFSense has several anchors for this purpose
            For example, the anchor "userrules"

            # User-defined rules follow
            
            anchor "userrules/*"
            

            According to this principle, a bunch of Fail2ban+Packet Filter works

            root@fr:/usr/local/etc/fail2ban # pfctl -a f2b/SSH -sr
            block drop log quick proto tcp from <f2b-SSH> to any port = ssh
            root@fr:/usr/local/etc/fail2ban # pfctl -a f2b/SSH -t f2b-SSH -Ts
               85.225.16.184
            root@fr:/usr/local/etc/fail2ban # 
            
            
            1 Reply Last reply Reply Quote 0
            • jimpJ
              jimp Rebel Alliance Developer Netgate
              last edited by

              There is no API for this (yet), though there is the easyrule script which may not help directly, but you could copy its code to potentially setup something.

              Having an IDS inject rules is a fine idea in general, though. We have demonstrated this working in TNSR using its API combined with ERSPAN to feed packets to the IDS: https://github.com/Netgate/TNSR_IDS/

              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.