The pfSense Store

Author Topic: pfBlocker  (Read 183774 times)

0 Members and 1 Guest are viewing this topic.

Offline marcelloc

  • Hero Member
  • *****
  • Posts: 10004
  • Karma: +5/-0
    • View Profile
pfBlocker
« on: October 29, 2011, 07:08:54 am »
PfBlocker is a new package that block countries and IP ranges. It joins Countryblock and IPblocklist.

The main goal of this package evolution was writing a package that only uses native functions of pfsense 2.0 instead of file hacks and table manipulation.

Current version is 1.0 and includes:

  • Countryblock features
  • Ipblocklist features
  • Dashboard widget
  • XMLRPC Sync
  • Dashboard widget with aliases applied and package hit
  • Lists update frequency
  • Many new options to choose what to block and how to block. If you want, you can assign network lists to your own rules.


This package is developed and maintained by marcelloc and tommyboy180.

« Last Edit: November 17, 2011, 12:04:01 pm by marcelloc »

Offline kilthro

  • Full Member
  • ***
  • Posts: 174
  • Karma: +0/-0
    • View Profile
Re: pfBlocker
« Reply #1 on: October 29, 2011, 09:59:33 am »
Thanks for all of the hard work to create this. You and Tommyboy180 have done a great job! I am waiting for most of the quirks to be worked out before I install it. I cant wait. :-)

Offline marcelloc

  • Hero Member
  • *****
  • Posts: 10004
  • Karma: +5/-0
    • View Profile
Re: pfBlocker
« Reply #2 on: October 29, 2011, 10:02:11 am »
All issues we found has already been fixed.

The last thing to code is lists update frequency.



Offline Supermule

  • Hero Member
  • *****
  • Posts: 1495
  • Karma: +2/-1
    • View Profile
Re: pfBlocker
« Reply #3 on: October 29, 2011, 10:19:52 am »
Is this compatible with 1.2.3??
Kind regards Brian


Offline marcelloc

  • Hero Member
  • *****
  • Posts: 10004
  • Karma: +5/-0
    • View Profile
Re: pfBlocker
« Reply #4 on: October 29, 2011, 10:23:04 am »
No. Just for 2.0.

Pfsense 1.2.3 does not have many features that pfBlocker uses.

Offline Supermule

  • Hero Member
  • *****
  • Posts: 1495
  • Karma: +2/-1
    • View Profile
Re: pfBlocker
« Reply #5 on: October 29, 2011, 10:24:47 am »
ok :)
Kind regards Brian


Offline tommyboy180

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 976
  • Karma: +0/-0
    • View Profile
    • TomSchaefer.org
Re: pfBlocker
« Reply #6 on: October 29, 2011, 10:26:43 am »
IP-Blocklist and Countryblock will remain available for 1.2.3.
-Tom Schaefer
SuperMicro 1U 2X Intel pro/1000 Dual Core Intel 2.2 Ghz - 2 Gig RAM
TomSchaefer.org/pfsense
Please support Countryblock | IP-Blocklist | File Browser | Strikeback Here

Offline Supermule

  • Hero Member
  • *****
  • Posts: 1495
  • Karma: +2/-1
    • View Profile
Re: pfBlocker
« Reply #7 on: October 29, 2011, 10:39:52 am »
Thks Tom. Havent changed yet since the 2.0 platform is not totally there yet. :)

It will be soon I hope....
Kind regards Brian


Offline tommyboy180

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 976
  • Karma: +0/-0
    • View Profile
    • TomSchaefer.org
Re: pfBlocker
« Reply #8 on: October 29, 2011, 04:50:45 pm »

Version 1.3 problems.

Error: Ipblocklist .txt feature does not work. I have to use .gz file type on txt lists. My recommendation is to remove the URL format option.
Reason: All clear text lists will correctly work regardless of extension. If the list is compressed then it must use .gz as the extension.
Fix: Therefore we can remove the user selection and treat every URL as .gz regardless of extension.

Error: If no interfaces are selected then the package will not process
Reason:  pfctl is looking for an interface in the rule syntax (“pass  in  quick  on $LAN )”
Fix: IP-blocklist uses “any” as the default interface. I highly recommend using “any” as the default interface. We can at least have it as an option in the selection box. I get the best results using “any” in ipblocklist and countryblock.

Error: switching inbound and outbound interfaces stops pfblocker from running correctly after saving settings
Reason: unknown
Fix: unknown
Note: After changing interfaces on the fly and saving the settings the rules entry for pfblock are removed from rules.debug even though the table is still defined. Even after a filter reload the package still isn’t working

Error: Selecting loopback as an interface causes rules to be removed from rules.debug
Reason: unknown
Fix: unknown

Error: After blocking a specific IP with action “Deny Outbound” with ipblocklist feature I’m still able to ping
Reason: I’m not exactly sure, but I didn’t have this behavior in ipblocklist
Fix: unknown


Also I figured out fetch.
Problem: When adding dynamic links like http://list.iblocklist.com/?list=bt_ads&fileformat=p2p&archiveformat=gz the package tries to download the file.
Reason: Fetch breaks because of the & symbols. So since the begging of IPblocklist we’ve always had to use direct URLs.
Fix: Parse the URL in “”. So
Code: [Select]
fetch http://list.iblocklist.com/?list=bt_ads&fileformat=p2p&archiveformat=gz will break but
Code: [Select]
fetch –o FILENAME http://list.iblocklist.com/?list=bt_ads&fileformat=p2p&archiveformat=gz will work!
You will have to assign a file name to each file otherwise the default filename will be something like “?list=bt_ads&fileformat=p2p&archiveformat=gz”


I haven’t had the time to find sample code changes for the above problems. I’m still looking deeper into the reason why some of those errors occur.


 

-Tom Schaefer
SuperMicro 1U 2X Intel pro/1000 Dual Core Intel 2.2 Ghz - 2 Gig RAM
TomSchaefer.org/pfsense
Please support Countryblock | IP-Blocklist | File Browser | Strikeback Here

Offline marcelloc

  • Hero Member
  • *****
  • Posts: 10004
  • Karma: +5/-0
    • View Profile
Re: pfBlocker
« Reply #9 on: October 29, 2011, 05:21:28 pm »
Erros fixed :

  • table reload is now forced after each config change
  • fix wrong php function to get clear text lists from url

Not erros:
When you choose no interfaces, pfBlocker creates only Aliases for any custom rules you want.
some examples:
  • block only smtp from top spammers
  • Block everything except inbound 80



Many thanks to tommyboy180.

NOTE:
These fixes solves almost all erros tommyboy180 found in 1.3
pfctrl was not reloading tables so almost all tests failed.
while doing new tests, check diagnostics -> tables updates.
I've did same tests after fix and seems to be ok for me.

how to apply? reinstall package.
« Last Edit: October 29, 2011, 10:53:14 pm by marcelloc »

Offline johnnybe

  • Hero Member
  • *****
  • Posts: 1395
  • Karma: +0/-0
  • I've got... a head with wings
    • View Profile
    • nextsense blog
Re: pfBlocker
« Reply #10 on: October 29, 2011, 06:40:15 pm »
Congratulations marcelloc and tommyboy180!
Very well done.

Just a note:
A better brief description in the Package Manager, and probably the most important: a Package Info link with more details.
Does it blocks MSN, Facebook, Orkut and this or that even behind a transparent Proxy or not?
you would not believe the view up here

Offline marcelloc

  • Hero Member
  • *****
  • Posts: 10004
  • Karma: +5/-0
    • View Profile
Re: pfBlocker
« Reply #11 on: October 29, 2011, 07:57:15 pm »
If you have social networks ip ranges on a url, it will work on transparent proxies.

If you have squid on same pfsense you have to create a custom floating rule for this.

« Last Edit: October 29, 2011, 10:28:14 pm by marcelloc »

Offline AhnHEL

  • Sr. Member
  • ****
  • Posts: 572
  • Karma: +0/-0
    • View Profile
Re: pfBlocker
« Reply #12 on: October 30, 2011, 01:19:00 am »
Trying out your new pfblocker, awesome idea to combine packages.

I've added about 13 iblocklist lists in gz format and I'm getting this error on save.

Code: [Select]
php: /pkg_edit.php: New alert found: pfBlockerInbound alias table is too large. Reduce Inbound list or increase "Firewall Maximum Table Entries" value to at least 818134 in "system - advanced - Firewall/NAT".

I have 4 gigs RAM and my current Table Entries Size is 100000 so i raised it to 1000000.  Enabled pfblocker and hit save and then got this

Code: [Select]
php: : There were error(s) loading the rules: /tmp/rules.debug:18: cannot define table pfBlockerInbound: Cannot allocate memory pfctl: Syntax error in config file: pf rules not loaded - The line in question reads [18]: table <pfBlockerInbound> persist file "/var/db/aliastables/pfBlockerInbound.txt"
Oct 30 02:11:29 php: : New alert found: There were error(s) loading the rules: /tmp/rules.debug:18: cannot define table pfBlockerInbound: Cannot allocate memory pfctl: Syntax error in config file: pf rules not loaded The line in question reads [18]: table <pfBlockerInbound> persist file "/var/db/aliastables/pfBlockerInbound.txt"
Oct 30 02:11:26 php: : The command '/sbin/pfctl -o basic -f /tmp/rules.debug' returned exit code '1', the output was '/tmp/rules.debug:18: cannot define table pfBlockerInbound: Cannot allocate memory pfctl: Syntax error in config file: pf rules not loaded'

Neither IPblocklist nor countryblock were installed when i installed pfblocker.  Memory usage is at 19%.

Line 18 in /tmp/rules.debug
Code: [Select]
table <pfBlockerInbound> persist file "/var/db/aliastables/pfBlockerInbound.txt"
« Last Edit: October 30, 2011, 01:33:23 am by onhel »
AhnHEL (Angel)
NYC

3 pfSense sites: 2.1 RELEASE (amd64)
Dell 745 SFF E4400 @ 2.0Ghz, 2GB RAM, 20/5 Mbps
Dell 755 SFF E6550 @ 2.3Ghz, 2GB RAM, 20/5 Mbps
White Box i5 3570k @ 4.4Ghz, 16GB RAM, 114/6 Mbps, SSD
OpenVPN (Site to Site, Road Warrior), IPSec Mobile, UPnP Gaming, Traffic Shaping, Snort, Suricata

Offline marcelloc

  • Hero Member
  • *****
  • Posts: 10004
  • Karma: +5/-0
    • View Profile
Re: pfBlocker
« Reply #13 on: October 30, 2011, 05:52:37 am »
Did you tried to reaply pfBlocker config, after increasing Firewall Maximum Table Entries to 1000000?

It seems that your change in "Firewall Maximum Table Entries" value did not take effect.

Cannot allocate memory pfctl: Syntax error in config file error is exactly what happens when  "Firewall Maximum Table Entries"  is lower then applied table size.

EDIT
Last package update was about 08 hours ago without version changing, so try to reinstall package to be sure you are on latest version.
« Last Edit: October 30, 2011, 06:29:28 am by marcelloc »

Offline dhatz

  • Hero Member
  • *****
  • Posts: 1002
  • Karma: +0/-0
    • View Profile
Re: pfBlocker
« Reply #14 on: October 30, 2011, 08:16:19 am »
I'm looking forward to trying the new package, when you'll add configurable update frequency.

I'm currently using a couple of shell scripts, to add pf tables of unwanted IPs to pfsense, e.g.

http://www.spamhaus.org/drop/drop.lasso
DROP (Don't Route Or Peer) is an advisory "drop all traffic" list, consisting of stolen 'hijacked' netblocks and netblocks controlled entirely by professional spammers. DROP is a tiny subset of the SBL designed for use by firewalls and routing equipment.

http://feeds.dshield.org/top10-2.txt
DShield's current Most Active Attacking IPs
(Same data as is used on DShield.org Top 10 Most Wanted.)
0 = IP Address, 1 = Resolved domain of IP Address

which are both updated on a daily basis.