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

Blocking a list of IP addresses via script

Scheduled Pinned Locked Moved Firewalling
2 Posts 2 Posters 350 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.
  • P
    Pelagic
    last edited by Oct 9, 2017, 11:29 PM

    Hi,

    I'm new to pfSense and would like to Block/Reject a list of several hundred IP addresses and address ranges.

    Is there a simple way of scripting this list into an alias to load into my dedicated pfSense machine?

    E.g. something like a scripted list of "netsh" commands as you can use in Windows command prompt:
    netsh advfirewall firewall add rule name="avoidthissite" dir=out action=block remoteip=123.123.123.017 enable=yes

    If this is possible in pfSense, please give an example of the syntax of how would I specify a range of addresses?  E.g. 123.123.123.001 - 123.123.123.255, setting "Reject" on the outbound, and "Block" on inbound?

    If I create such a script on another computer and put it on a flash drive, what are the steps in getting it into pfSense?  (Again, I am new to this environment, and don't know how to use SSH, etc., so it would be really helpful if you can describe the steps.)

    Thanks!

    1 Reply Last reply Reply Quote 0
    • K
      KOM
      last edited by Oct 10, 2017, 6:43 PM

      Instead of guessing at a solution and then asking for steps, why not tell us what you are trying to accomplish?

      pfSense supports URL Table aliases:

      https://doc.pfsense.org/index.php/Aliases

      URL Table Aliases
      A URL table alias is a URL that points to a plain text file containing IP and/or CIDR masked network addresses. The URL will be periodically downloaded and refreshed. The contents of the file would look like so:

      192.0.2.0/24
      172.22.59.49
      192.168.0.128/26

      Come up with a text file and put it on a web server and the rest is easy.  pfSense will download the file per the schedule you set and add everything to an alias that you can use in a firewall rule.

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