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

    Block if X connections to a port in time frame

    Scheduled Pinned Locked Moved Firewalling
    8 Posts 6 Posters 3.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
      BenKenobe
      last edited by

      Is it possible to somehow block an IP address if it makes too many attempts to 'connect' to a port i.e. 25.

      Our mailserver (Kerio) is OK but it will happily let connections do brute force type attacks - why can't it do something like our firewall - i.e 10 tries then kick and ban.

      Well it can't so can I replicate this in pFSense somehow - been playing but it seems not.

      I've had a connection in Brazil thats been trying for 6 hours to log into our mail server that I have now blocked manually but it would be real nice if I could do this automatically. The culprit was trying 4 or five passwords per second.

      1 Reply Last reply Reply Quote 0
      • pttP
        ptt Rebel Alliance
        last edited by

        Have you tried/played with this/or any other Firewall Rule Advanced Option ?

        FW_Rule_Advanced.PNG
        FW_Rule_Advanced.PNG_thumb

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

          You can limit the connection attempts from a single IP through Firewall > Rules > edit rule > Advanced features > Advanced Options.

          If it's only the mail server you're worried about, I would definitely recommend installing the Postfix Forwarder package on pfSense.

          I had the same problem with MailEnable.  Now the mail server's logs are really boring.

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

            I'll have a play with both. I had looked at the postfix forwarder but the description seemed to relate only to forwarding - but how does it respond to 'hammering' or brute force type attacks - I'm assuming that it will still respond to each and every request.

            The best possible 'password' system is one that doesn't provide any response whether you are correct or not. a password module that simply says - no try again indefinitely is very poor in my opinion. My Mail server will block a valid user if the password is wrong too often but will happily respond 'nope user doesn't exist' …

            1 Reply Last reply Reply Quote 0
            • D
              doktornotor Banned
              last edited by

              @BenKenobe:

              The best possible 'password' system is one that doesn't provide any response whether you are correct or not.

              Sorry, this breaks relevant RFCs heavily. You'll break and lose your mail. Get the mailserver fixed so that it limits the number of failed attempts, or get a better mailserver or proxy it.

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

                @BenKenobe:

                I had looked at the postfix forwarder but the description seemed to relate only to forwarding - but how does it respond to 'hammering' or brute force type attacks - I'm assuming that it will still respond to each and every request.

                Postfix stopped the "hammering" problem for me - as well as the bots.  You would have to read through the voluminous Postfix documentation to get a good feel for exactly how it achieves that but a few things that have made a huge difference for me are:

                • Ability to suck up hundreds of connections and calmly deal with them - your mail server never gets to see them.

                • Greylisting - "Sorry, I'm busy now. Come back later" - which they never do.

                • Enforcing strict SMTP protocol adherence.

                • Reverse DNS checking

                You can add spam filters and block lists to the package but I haven't had to bother with those yet.

                1 Reply Last reply Reply Quote 0
                • D
                  dcol Banned
                  last edited by

                  I also need to do something about brute force spammers on port 25. Looks like PostFix is no long an option in the available packages with release 2.3.1. The question I have with the other suggestion of using the advanced options is where and how long does the IP get blocked?

                  1 Reply Last reply Reply Quote 0
                  • N
                    Nachtfalke
                    last edited by

                    Hi,

                    perhaps snort can help you if it detects brute-force attacks on this port and then blocks the "attacker" for a specific time.
                    Having a short look at google gave me this thread. Perhaps it will help you:

                    https://forum.pfsense.org/index.php?topic=72632.0

                    Regards

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