The purpose of this document is to describe the integration process for ThreatSTOP DNS Firewall into an existing BIND 9.8+ deployment. This document is written under the condition that you have an existing DNS deployment and are looking to add the ThreatSTOP DNS Firewall to your existing network infrastructure. This is done by placing the DNS Firewall between your existing DNS configuration and your external connection. This will allow ThreatSTOP DNS Firewall to guard against hostile connections.
A birds-eye view of the setup procedure is:
- Open a ThreatSTOP account if you have not already done so.
Specify that you are setting up a DNS Firewall in order to receive any needed materials.
- In the Device section of the Portal, configure a new device with the following settings:
- Manufacturer: DNS Server
- Model: BIND 9.8+
More information about setting up Devices in the Portal can be found in the Introduction.
- You will then need to configure the rest of the Portal to service a ThreatSTOP DNS Firewall as explained in ThreatSTOP DNS Firewall.
- Configure BIND itself to act as a slave server for the zone that contains your policy.
- Configure the client machines to be protected to use the ThreatSTOP DNS Firewall for address resolution.
The ThreatSTOP BIND based DNS Firewall on Ubuntu will require a VM that meets at least the following specifications:
The following steps will walk you through the configuration of BIND to serve you ThreatSTOP DNS Firewall. Note that these steps begin after the account creation process has finished.
In the ThreatSTOP Portal
In the ThreatSTOP portal add a DNS Firewall policy. To do this:
- Click on Policies & Lists.
- Then on the DNS FW Policy tab.
- Select + Add Policy.
- Set a Policy name: in the corresponding field.
If you want to change the default behavior of the RPZ Target Lists being used set it in the Default Behavior field.
The available behaviors are:
- Select the RPZ Target Lists you want to block. For our example we'll use the BASIC list with the default behavior.
If you want a specific list to be treated differently from other included lists, change the Behavior dropdown to the desired action.
This dropdown will override the Default Behavior field.
- Click on Submit to save your changes.
- Click on Devices and then on + Add Device.
- Enter a Nickname for the device, this should probably be something descriptive of the device.
- Set the Manufacturer and Model to:
- Manufacturer: DNS Server
- Model: BIND 9.8+
Set the IP Type as defined by your network needs.
Using a Dynamic IP address is far outside of best practices and is not recommended. Unexpected results can occur if this setting is used.
- The IP Address of the device is the external IP address (unsecured side of the firewall). This can be determined by visiting: http://www.threatstop.com/cgi-bin/validip.pl
- Select the DNS Firewall policy you defined previously in the Policy drop down
Deploying and Configuring BIND
The following procedure will provide a default install of BIND (BIND 9.8.2 and greater). This has been shown to work in testing by ThreatSTOP resources, and should provide a working installation in your environment. After successfully deploying the installation and configuring logging you should be able to simply use this box as a drop-in replacement for your existing DNS server, and will automatically receive the ThreatSTOP protection policy you've chosen in the ThreatSTOP portal.
Download and Install BIND
To start we'll need to download and install BIND. To do this:
Login to your administrator account, and elevate your access level (if not already logged in and granted elevated privileges). To do this, login and enter:
Next we'll need to download and install BIND and it's utilities, this can be done with the command:
Next we'll need to enable and start bind with the following command:
Then verify that things went according to plan by checking the logs:
Check the installed version matches at least 9.8.2 for example:
Create directories and set permissions
To prepare for our incoming zone files we need to make a little room for them in the file system, to do this:
Make a directory for the zone files using the following command:
Set permissions and ownership of the zone directory to BIND:
Make a directory for the named log files using the following command:
Set permissions and ownership for the log file directory:
Edit BIND config files
Next we'll start configuring BIND itself, to do this we'll need a gather a few pieces of information, and drop them into the appropriate places in the configuration file. We'll need:
The device's internal IP address. You can gather this with the following command at the command prompt:This will list all available network devices, note the inet address for the interface with which you want your other network devices to communicate.
We need the device's external IP address, you can get this using this command from the device:
The policy name for your device. Which is provided here for reference, and should also appear in the configuration data below in bold.
The secret key for your RPZ, this is provided by the ThreatSTOP Support team.
Let's start editing the configuration files to get you up and running:
We need to start by editing /etc/named.conf to match the following:
The 192.0.2.0 address below will need to be replaced with the IP address gathered with the ifconfig command above.
Create /etc/named.conf.options using the command
vi /etc/named.conf.optionsthen edit it to match the following:
Create /etc/named.conf.local using the command
vi /etc/named.conf.localand then add the following:
Set ownership on files:
Set named to start on boot:
Logging and Restarting the Service
After configuring the BIND server to use ThreatSTOP's Threat Intelligence lists, you can start sending your logs to ThreatSTOP, which will then be used to help re-enforce our community's Threat Intelligence.
Before starting in on this section, certain prerequisites need to be met:
Your system will need to be configured to run logrotate, and must have curl, stat, md5sum, and cut utilities.
The following packages are available for these utilities on Ubuntu 14.04:
- curl: sudo apt-get install curl
- logrotate: sudo apt-get install logrotate
stat, md5sum, and cut are all part of the core Ubuntu 14.04 distribution, and should automatically install with the OS.
After ensuring these programs are present you can start uploading logs back to ThreatSTOP using logrotate to do this:
Change directory to the logrotate.d folder and create a new file called threatstop
Copy and paste the example below to /etc/logrotate.d/threatstopAdjust the value fw_ip to match the IP address entered on the portal. This is typically the external IP provided by https://www.threatstop.com/cgi-bin/validip.pl
The curl solution above assumes the following:
- The system has curl, stat, md5sum and cut and they are located at the paths specified
- logrotate, rotates logs and the latest rotated log is $1 with ".1" appended. In this example it would be: /var/log/named/rpz.log.1
- The user will update the fw_ip value to the actual value for their device
sudo service bind9 reloadand press ENTER.
sudo is not required for users logged in with administrative privileges.
Finally, add the log rotation to cron, to do this:
Edit crontab using the following command:
Add the following line to crontab:
Sending Log Information to More Than One Destination
The configuration above will upload the rotated file to ThreatSTOP and–if specified–wherever the second command in the postrotate section sends it. If the data is to be sent to a syslog server however, the process is simplified by adding a second BIND channel in rpz.log as shown in the configuration below:Follow this up with forwarding the syslog configuration to the SIEM (based on your setup). For example, with rsyslog:
To test that your configuration is up and running you'll need to setup a temporary test policy in the ThreatSTOP portal. Any policy added to this list should have the RPZ behavior set to NXDOMAIN or DROP. After setting this: