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

    Linux script to Add Host Blocking to pfSense?

    Scheduled Pinned Locked Moved pfSense Packages
    7 Posts 5 Posters 4.8k 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.
    • Z
      zktech
      last edited by

      I have several system that are hit with prob scripts several times a day trying to break in. I can detect the probing on the linux box and block it on the box's firewall. What I want to do is to add the ip address to a pfSense Aliases that is used to block the offending IP's for the entire network.

      How would I go about writing a script that would add a host to an existing aliases. Cause pfSense to reload so it sees the new aliases host list, and then reload the state tables to ensure that any current probing connections would be blocked. I have ssh access to the pfSense routers from the Linux boxes.

      Any ideas or examples would be apperciated.
      zktech

      1 Reply Last reply Reply Quote 0
      • T
        tommyboy180
        last edited by

        What your looking for is a package called IP-Blocklist.

        -Tom Schaefer
        SuperMicro 1U 2X Intel pro/1000 Dual Core Intel 2.2 Ghz - 2 Gig RAM

        Please support pfBlocker | File Browser | Strikeback

        1 Reply Last reply Reply Quote 0
        • Z
          zktech
          last edited by

          I am using IP-Ban on linux what I need to do is have some way to trigger from my ip-ban scripts adding the banded host ip to my pfSense blocked alaises list then reload the system so it uses the new list and then reset the state tables so that the new list of blocked host ip's is read from the alaises list.

          Is IP-Blocklist a module for pfSense?

          1 Reply Last reply Reply Quote 0
          • T
            tommyboy180
            last edited by

            If your looking for an automated trigger program then denyhosts will do that for you. It monitors SSH and other auth services. After 3 failed login attempts the IP is banned.
            IP-Blocklist is a manual method. You enter IP lists that are banned. There are lists of IPs that are known bad. It's more of a preventive approach.

            -Tom Schaefer
            SuperMicro 1U 2X Intel pro/1000 Dual Core Intel 2.2 Ghz - 2 Gig RAM

            Please support pfBlocker | File Browser | Strikeback

            1 Reply Last reply Reply Quote 0
            • G
              grazman
              last edited by

              I have tried to use ip blocklist (thanks tommyboy), but the blocklists I need are hosted and not in the dansguardian2 format.

              I would imagine I can call them from a cron job thusly…

              fetch http://www.infiltrated.net/voipabuse/addresses.txt |
              awk '{print "/sbin/pfctl -t voipblocklist -Tadd "$1}'

              Does anyone have any suggestions for creating the table and making it persist in /tmp/rules.debug with pfSense? I'd rather not do this manually, but it seems all the blocking solutions available won't accept a simple list.

              1 Reply Last reply Reply Quote 0
              • jimpJ
                jimp Rebel Alliance Developer Netgate
                last edited by

                Use the URL Table package. It does exactly that: fetches an IP or IP/CIDR list of IPs from a text file by URL, and puts them into a table.

                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
                • jnorellJ
                  jnorell
                  last edited by

                  zktech, you might look at the snort package in pfSense, too - even the portscan preprocessor (ie. without downloading any snort rulesets) catches a lot of ssh port scans, and can automatically block (and later remove) the scanning ip addrs.

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