Installing BIND 9.8+ on Ubuntu varies slightly between the major revisions of Ubuntu, the following directions cover the versions of Ubuntu supported by ThreatSTOP.
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.
Deploying and Configuring Ubuntu
Ubuntu has developed a standard installation process that works with both of their current deployments. The stock install includes nearly everything we need to get the system up and running including activating Network Time Protocol (NTP) which is needed to ensure synchronization between ThreatSTOP's servers and the DNS Firewall.
- 1GB disk space on the host system for the Ubuntu ISO
- Hypervisor capable of creating or importing the Ubuntu ISO (VMware, VirtualBox, or similar)
- The VM will need to be provided with at least the minimum installation requirements for Ubuntu 14.04 for our example we're using:
- 2048 MB RAM
- 10 GB Harddrive space
- Bridged network connections
- An open connection to the Internet from your new device
Creating the VM
We'll cover the installation from the point that the computer is booted with the installation disc in the drive/the ISO is loaded into the VM and the VM is started.
- Select your setup Language.
- Select Install Ubuntu Server.
- Select your installation Language.
- Select your location.
- For Configure the keyboard select No. We'll select this manually.
- Select the correct language for your keyboard.
- Select the correct layout for your keyboard.
The initial setup files will be copied to your hard drive.
- Select the primary network interface.
- Designate a hostname for the system.
- Enter the full name of the Administrator for the system.
- Adjust the Username for the account if needed.
- Provide, and confirm the password for the administrator account.
Optionally encrypt your home directory.
While encrypting your home directory, and later your drive, is not mandatory it may be seen as beneficial from a security standpoint.
Verify that the Time Zone is correct. If it is not select the correct time zone.
This information is used to configure Network Time Protocol (NTP) services automatically. Which will help prevent issues that can appear during zone transfer.
- Select the partitioning method you wish to use.
- Select the disk to partition.
- Write the changes to the disk.
- If you chose to encrypt your drive enter an encryption passphrase and verify it.
- Accept the default volume size.
- Write the changes to the disk.
If you use a proxy to access the Internet enter the corresponding information.
Under Software selection check the box next to DNS server. This will save us a little time in patching.
- Install the GRUB Boot Loader to allow the drive to boot.
- Remove the disc from the drive (it's likely this will be done automatically for you) and click Continue to reboot into the new system.
- Login to the system using the administrator account created during system setup.
Install the latest patches and security updates with the following commands:
This will complete your Ubuntu VM deployment and allow you to successfully setup and install the ThreatSTOP DNS firewall solution to your device.
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:For Debian based distros (Debian, Ubuntu, etc.):For Red Hat based distros (RHEL, CentOS, etc.)
Next we'll need to enable and start bind with the following command:For Debian based distros (Debian, Ubuntu, etc.):
sudo /usr/sbin/services restart namedFor Red Hat based distros (RHEL, CentOS, etc.)
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:For Debian based distros (Debian, Ubuntu, etc.)For Red Hat based distros (RHEL, CentOS 7+, etc.)
This will list all available network devices, note the inet address for the interface with which you want your other network devices to communicate.
CentOS 6.8 uses the
ifconfigcommand to gather network information.
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 Sales team during your sign-up.
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:
The provided TSIG key is only valid for trial accounts and will change for paid accounts.
Set ownership on files:
Set named to start on boot:
setsebool to write the zone file to filesystem:
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/threatstop
Adjust 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
Enter sudo service bind9 reload and press ENTER.
sudo is not required for users logged in with administrative privileges.
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: