Install and Configure pfBlockerNg For DNS Black Listing in Pfsense Firewall
Install and Configure pfBlockerNg For DNS Black Listing in Pfsense Firewall
Menu
This article is going to talk about a wonderful add-on package for pfsense called
pfBlockerNG.
As the capabilities of attackers and cyber criminals continues to advance, so must
the defenses that are put in place to thwart their efforts. As with anything in the
computing world, there isn’t a one solution fixes all product out there.
pfBlockerNG provides pfSense with the ability for the firewall to make allow/deny
decisions based items such as the geolocation of an IP address, the domain name
of a resource, or the Alexa ratings of particular websites.
This guide will walk through configuring a pfSense firewall device to use the
pfBlockerNG package as well as some basic examples of domain block lists that
can be added/configured into the pfBlockerNG tool.
Requirements
This article will make a couple of assumptions and will build off of the prior
installation article about pfSense. The assumptions will be as follows:
Lab Diagram
The image below is the lab diagram for the pfSense environment that will be used
in this article.
Some browsers may complain about the SSL certificate, this is normal since the
certificate is self signed by the pfSense firewall. You can safely accept the warning
message and if desired, a valid certificate signed by a legitimate CA can be
installed but is beyond the scope of this article.
pfSense SSL Warning
After successfully clicking ‘Advanced’ and then ‘Add Exception…’, click to confirm
the security exception. The pfSense login page will then display and allow for the
administrator to log in to the firewall appliance.
Once logged in to the main pfSense page, click on the ‘System’ drop down and then
select ‘Package Manager’.
Clicking this link will change to the package manager window. The first page to
load will be all the currently installed packages and will be blank (again this guide is
assuming a clean pfSense install). Click on the text ‘Available Packages’ to be
provided a list of installable packages for pfSense.
pfSense Available Packages
Once the ‘Available Packages’ page loads, type ‘pfblocker’ into the ‘Search term’
box and click the ‘Search’. The first item that is returned should be pfBlockerNG.
Locate the ‘Install’ button to the right of the pfBlockerNG description and click the
‘+’ to install the package.
The page will reload and request the administrator confirm the installation by
clicking ‘Confirm’.
Once confirmed, pfSense will begin to install pfBlockerNG. Do not navigate away
from the installer page! Wait until the page displays successful installation.
pfBlockerNG Installation
Once the installation has been completed, the pfBlockerNG configuration can begin.
The first task that needs to be completed though is some explanations on what is
going to happen once pfBlockerNG is configured properly.
The pfSense firewall needs to intercept DNS requests in order to be able to filter out
bad domains and will use a local DNS resolver known as UnBound. This means
clients on the LAN interface need to use the pfSense firewall as the DNS resolver.
If the client requests a domain that is on pfBlockerNG’s block lists, then pfBlockerNG
will return a false ip address for the domain. Let’s begin the process!
When the page reloads, the DNS resolver general settings will be configurable. This
first option that needs to be configured is the checkbox for ‘Enable DNS Resolver’.
The next settings are to set the DNS listening port (normally port 53), setting the
network interfaces that the DNS resolver should listen on (in this configuration, it
should be the LAN port and Localhost), and then setting the egress port (should be
WAN in this configuration).
Once the selections have been made, be sure to click ‘Save’ at the bottom of the
page and then click the ‘Apply Changes’ button that will appear at the top of the
page.
The next step is the first step in configuration of pfBlockerNG specifically. Navigate
to the pfBlockerNG configuration page under the ‘Firewall’ menu and then click on
‘pfBlockerNG’.
pfBlockerNG Configuration
Once pfBlockerNG has loaded, click on the ‘DNSBL’ tab first to begin setting up the
DNS lists before activating pfBlockerNG.
When the ‘DNSBL’ page loads, there will be a new set of menus beneath the
pfBlockerNG menus (highlighted in green below). The first item that needs to be
addressed is the ‘Enable DNSBL’ check box (highlighted in green below).
This check box will require the UnBound DNS resolver be used on the pfSense box
in order to inspect dns requests from LAN clients. Don’t worry UnBound was
configured earlier but this box will need to be checked! The other item that needs to
be filled in on this screen is the ‘DNSBL Virtual IP’.
This IP needs to be in the private network range and not a valid IP on the network in
which pfSense is being used. For example, a LAN network on 192.168.0.0/24 could
use an IP of 10.0.0.1 as it is a private IP and isn’t part of the LAN network.
This IP will be used to gather statistics as well as monitor domains that are being
rejected by pfBlockerNG.
Scrolling down the page, there are a few more settings worth mentioning. The first
is the ’DNSBL Listening Interface’. For this setup, and most setups, this setting
should be set to ‘LAN’.
The other setting is ‘List Action’ under ‘DNSBL IP Firewall Settings’. This setting
determines what should happen when a DNSBL feed provides IP addresses.
The pfBlockerNG rules can be setup to do any number of actions but most likely
‘Deny Both’ will be the desired option. This will prevent inbound and outbound
connections to the IP/domain on the DNSBL feed.
Configure DNSBL for pfSense
Once the items have been selected, scroll to the bottom of the page and click the
‘Save’ button. Once the page reloads, it is time to configure the DNS Block Lists that
should be used.
pfBlockerNG provides the administrator with two options that can be configured
independently or together depending on the administrator’s preference. The two
options are manual feeds from other web pages or EasyLists.
To read more about the different EasyLists, please visit the project’s homepage:
https://easylist.to/
The two EasyLists available in pfBlockerNG are ‘EasyList w/o Element Hiding’ and
‘EasyPrivacy’. To use one of these lists, first click on the ‘DNSBL EasyList’ at the top
of the page.
Configure DNSBL EasyList
Once the page reloads, the EasyList configuration section will be made available.
The following settings will need to be configured:
The next section is used to determine which parts of the lists will be blocked. Again
these are all user preference and multiple can be selected if desired. The important
settings in the ‘DNSBL – EasyList Settings’ are as follows:
When the EasyList settings are configured to the user’s preferences, be sure to
scroll to the bottom of the page and click the ‘Save’ button. Once the page reloads,
scroll to the top of the page and click on the ‘Update’ tab.
Once on the update tab, check the radio button for ‘Reload’ and then check the
radio button for ‘All’. This will run through a series of web downloads to obtain the
block lists selected on the EasyList configuration page earlier.
This must be done manually otherwise lists won’t be downloaded until the
scheduled cron task. Anytime changes are made (lists added or removed) be sure to
run this step.
Update EasyList Settings
Watch the log window below for any errors. If everything went to plan, client
machines on the LAN side of the firewall should be able to query the pfSense
firewall for known bad sites and receive bad ip addresses in return. Again the client
machines must be set to use the pfsense box as their DNS resolver though!
Notice in the nslookup above that the url returns the false IP configured earlier in the
pfBlockerNG configurations. This is the desired outcome. This would result in any
request to the URL ‘100pour.com’ being directed to the false IP address of 10.0.0.1.
In contrast to the AdBlock EasyLists, there is also the ability to use other DNS Black
Lists within pfBlockerNG. There are hundreds of lists that are used to track malware
command and control, spyware, adware, tor nodes, and all sorts of other useful
lists.
These lists can often be pulled into pfBlockerNG and also used as further DNS Black
Lists. There are quite a few resources that provide useful lists:
https://forum.pfsense.org/index.php?topic=114499.0
https://forum.pfsense.org/index.php?topic=102470.0
https://forum.pfsense.org/index.php?topic=86212.0
The links above provide threads on pfSense’s forum where members have posted a
large collection of the list’s they use. Some of the author’s favorite lists include the
following:
http://adaway.org/hosts.txt
http://www.malwaredomainlist.com/hostslist/hosts.txt
http://pgl.yoyo.org/adservers/serverlist.php?
hostformat=hosts&mimetype=plaintext
https://zeustracker.abuse.ch/blocklist.php?download=domainblocklist
https://gist.githubusercontent.com/BBcan177/4a8bf37c131be4803cb2/raw
Again there are tons of other lists and the author strongly encourages that
individuals seek out more/other lists. Let’s continue with the configuration tasks
though.
Once on the DNSBL configuration page again, click on the ‘DNSBL Feeds’ text and
then click on the ‘Add’ button once the page refreshes.
The add button will allow the administrator to add more lists of bad IP addresses or
DNS names to the pfBlockerNG software (the two items already in the list are the
author’s from testing). The add button brings the administrator to a page where
DNSBL lists can be added to the firewall.
Once these settings have been set, click the save button down at the bottom of the
page. As with any changes to pfBlockerNG, the changes will take effect on the next
scheduled cron interval or the administrator can manually force a reload by
navigating to the ‘Update’ tab, click the ‘Reload’ radio button, and then click the
‘All’ radio button. Once those are selected, click the ‘Run’ button.
Watch the log window below for any errors. If everything went to plan, test that the
lists are working by simply attempting to do an nslookup from a client on the lan
side to one of the domains listed in one of the text files used in the DNSBL
configuration.
As can be seen in the output above, the pfSense device is returning the virtual IP
address that was configured in pfBlockerNG as the bad IP for the black list
domains.
At this point the administrator could continue tuning the lists by adding more lists or
creating custom domain/IP lists. pfBlockerNG will continue to redirect these
restricted domains to a fake IP address.
Thank you for reading this article about pfBlockerNG. Please show your
appreciation or support for the pfSense software as well as pfBlockerNG by
contributing in anyway possible to the continued development of both of these
wonderful products. As always please comment below with any suggestions or
questions!
PfBlockerNg , Pfsense
If you liked this article, then do subscribe to email alerts for Linux tutorials. If you
have any questions or doubts? do ask for help in the comments section.
Related Posts
How to Install and Configure Basic OpnSense Firewall
10 thoughts on “Install and Configure
pfBlockerNg for DNS Black Listing in pfSense
Firewall”
Bekir
July 29, 2021 at 7:36 pm
Thanks for the great article. I also recommend trying Sensei. It has a Free
Edition which is a very powerful web filtering and application control
engine.
Reply
seth b
June 22, 2020 at 2:12 pm
Reply
Ravi Saive
June 23, 2020 at 11:52 am
@Seth,
We are in process of updating this article with the latest instructions, till
then stay tuned…
Reply
Breno
May 10, 2020 at 9:46 pm
Reply
ameen
October 16, 2018 at 10:31 am
Dear Sir,
Reply
BobD
February 23, 2018 at 1:48 am
Pierre Andrieu
February 13, 2018 at 3:23 pm
Hello,
Thanks
Reply
dave
December 14, 2017 at 8:59 pm
Good work, helped me to get started and familiarize myself with concepts
covered in this guide.
Reply
Carl
September 5, 2017 at 7:59 am
Great article, thanks a lot. It helped me get set up and even works with
three interfaces (WAN, LAN, and OPT1 for my Wifi router).
About the only thing I found missing, and I only mention it because this is a
good step-by-step set of instructions to get you going, is to enable
pfBlockerNG first, Save, and then go to the DNSBL tab and continue with
the instructions. Yes, I did figure it out as it’s not all that hard but with step-
by-step, it should be complete :)
Reply
techgs
June 14, 2017 at 2:13 pm
Excellent work.
After reading your article I induced to use pfsense and results are far better
than expected. I wish you very best for suggesting this. I would say that the
solution is far better than commercial firewall.
Keep writing such beautiful, informative and helpful articles. All the best
Reply
Got something to say? Join the discussion.
Have a question or suggestion? Please leave a comment to start the discussion.
Please keep in mind that all comments are moderated and your email address will
NOT be published.
Name *
Email *
Save my name, email, and website in this browser for the next time I comment.
Notify me of followup comments via e-mail. You can also subscribe without
commenting.
Post Comment
This site uses Akismet to reduce spam. Learn how your comment data is processed.
A Beginners Guide To Learn Linux for Free [with Examples]
Exodus – Safely Copy Linux Binaries From One Linux System to Another
If You Appreciate What We Do Here On TecMint, You Should Consider:
How to Use ‘at’ Command to Schedule a Task on Given or Later Time in Linux
Tecmint: Linux Howtos, Tutorials & Guides © 2022. All Rights Reserved.
The material in this site cannot be republished either online or offline, without our permission.
Hosting Sponsored by : Linode Cloud Hosting