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

    Blocking IPs automatically based on certain alerts

    Scheduled Pinned Locked Moved IDS/IPS
    9 Posts 4 Posters 2.3k 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.
    • B
      bluepr0
      last edited by

      So I have started into the Snort world and I have read documents, tutorials and posts!

      I've created my first rule, and it works!. It just basically alerts me when someone tries to connect on SSH

      alert tcp $EXTERNAL_NET any -> $HOME_NET 22 (msg:"SSH from WAN";classtype:attempted-recon;sid:1000001; rev:1;)
      

      The next thing I tried to do is to detect several logins to SSH in a certain time. I found this rule on internet which it actually works as well, I tested it myself

      alert tcp $EXTERNAL_NET any -> $HOME_NET 22 (msg:"SSH from WAN several logins";flow:to_server;flags:S;threshold:type threshold, track by_src, count 3, seconds 60;classtype:attempted-dos;sid:2001219;rev:4; resp:rst_all;)
      

      I don't completely understand all of its variables, but I'm working on it. In any case, what I would like to achieve is that when a IP triggers this alert, to be able to automatically block it. I have read about activate/dynamic but dynamic rules are just like log rules, so they don't block anything.

      And if I enable "Block offenders" on General Settings, then I will block all offenders from the alerts (if I understood correctly) but I would like to keep some alerts as just alerts while block IPs from others!. Can anyone please point me in the right direction to achieve what I would like to do?

      Thanks!

      1 Reply Last reply Reply Quote 0
      • F
        fsansfil
        last edited by

        And if I enable "Block offenders" on General Settings, then I will block all offenders from the alerts (if I understood correctly) but I would like to keep some alerts as just alerts while block IPs from others!. Can anyone please point me in the right direction to achieve what I would like to do?

        Correct, right now thats the way it works on pfsense. When chosing block offenders, no matter if the rule is DROP or ALERT, the offender triggering the rule is move into a block pf table of the firewall.

        But you are trying too hard :)

        alert tcp ![1.1.1.1,2.2.2.2] -> $HOME_NET 22
        

        Replace 1.1.1.1 and 2.2.2.2 with the IP allowed to SSH, all other will get blocked. Those IP could be on your LAN or External, doesnt matter, only allow specific IP to SSH and block all others…

        F.

        1 Reply Last reply Reply Quote 0
        • B
          bluepr0
          last edited by

          @fsansfil:

          And if I enable "Block offenders" on General Settings, then I will block all offenders from the alerts (if I understood correctly) but I would like to keep some alerts as just alerts while block IPs from others!. Can anyone please point me in the right direction to achieve what I would like to do?

          Correct, right now thats the way it works on pfsense. When chosing block offenders, no matter if the rule is DROP or ALERT, the offender triggering the rule is move into a block pf table of the firewall.

          But you are trying too hard :)

          alert tcp ![1.1.1.1,2.2.2.2] -> $HOME_NET 22
          

          Replace 1.1.1.1 and 2.2.2.2 with the IP allowed to SSH, all other will get blocked. Those IP could be on your LAN or External, doesnt matter, only allow specific IP to SSH and block all others…

          F.

          thanks for your reply!
          Your example alert won't work in my case as my IP will be dynamic :(

          1 Reply Last reply Reply Quote 0
          • bmeeksB
            bmeeks
            last edited by

            For Suricata 3.0 and forward (and probably Snort 3.0 when it becomes available), I am looking to alter the old "default block" behavior for alerts to more accurately conform to IDS/IPS standards found elsewhere.  This means rules with the ALERT keyword will just alert, and only rules with the DROP keyword would block traffic.  That's NOT how it works today, though.  Today, any alert equals a block (when "block offenders" is enabled).

            Bill

            1 Reply Last reply Reply Quote 0
            • B
              bluepr0
              last edited by

              Yep! Any ideas about what I'm trying to achieve? Thanks!

              1 Reply Last reply Reply Quote 0
              • bmeeksB
                bmeeks
                last edited by

                @bluepr0:

                Yep! Any ideas about what I'm trying to achieve? Thanks!

                Right now, until a true "DROP" action is supported and differentiated from the "ALERT" action, I don't know of a way to achieve what you want.

                Bill

                1 Reply Last reply Reply Quote 0
                • B
                  bluepr0
                  last edited by

                  Ummm, maybe it can be achieved with other IDS? Like Suricata or some other package available in the package list?

                  1 Reply Last reply Reply Quote 0
                  • BBcan177B
                    BBcan177 Moderator
                    last edited by

                    You can add fail2ban or ossec to the Servers behind pfSense, and collect those banned IPs into a blocklist. Afterwards, import those into pfBlockerNG on a specified frequency.

                    "Experience is something you don't get until just after you need it."

                    Website: http://pfBlockerNG.com
                    Twitter: @BBcan177  #pfBlockerNG
                    Reddit: https://www.reddit.com/r/pfBlockerNG/new/

                    1 Reply Last reply Reply Quote 0
                    • B
                      bluepr0
                      last edited by

                      That's not really ideal to be honest :(, but thank for the idea!

                      It's really really annoying that Snort can't do this easily

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