Berkeley Internet Name Domain (BIND) is an open source, standards compliant DNS server. It can be commonly used to provide:
- Caching DNS server in the local network
- Authoritative DNS server for zones
- Secondary server to provide high availability for zones
As BIND can be used in a number of capacities, including serving public-facing DNS services, it can become a target for bad actors. To help protect the service against penetration and exploitation, there are a few options available limit any potential breach:
- Protect BIND with SELinux
- Operate BIND in a change-root environment
- Run BIND in a container
This article will focus on the second option: Operating BIND in a change-root environment.
While SELinux in enforcing
mode is seen as more secure as it prevents exploitation of known BIND security vulnerabilities, SELinux can pose potential operational difficulties with other aspects of the system. Runninf BIND in a change-root environment, while not as secure as SELinux, provides a good comprimise between a bare install and SELinux protection.
The change-root feature allows an adminitrator to define an alternate root directory for a process and its sub-processes. For example /var/named/chroot
can be defined as the root directory for named. The change-root mechanism prevents the named
process from accessing files outside of /var/named/chroot/
.
BIND: Installation and first run
(adapted from the RHEL BIND guide)
On RHEL derivatives, BIND is distributed under the bind
package prefix.
Edit the BIND configuration in /etc/named.conf
to enable basic functionality, replacing values inside the <>
brackets:
Save the file and validate the config for syntax errors:
Configure the firewall to accept DNS traffic:
Start the service and verify operation:
Stop the service in readiness to install the change-root package:
BIND change-root: Installation
Once the base installation of BIND has been tested, the change-root package, bind-chroot
, can be installed. Theoretically, you should be able to start with installation of bind-chroot
, but experience with starting with the change-root package has shown that it can result in unexpected behaviour and errors.
If named-chroot
starts without error, you can enable the service for operation:
With BIND operating in a change-root environment, you continue to configure the DNS server with zones, access control and options as required.
Configuring logging
Effective logging aids in the administration and management of the service. Enable the various channels to define the BIND logging functionality.
Create the directory structure and permissions required to support the logging functions:
Zone transfer logging:
Query logging:
Validate the config for syntax errors:
Configure DNSSEC
DNSSEC is used to provide zone signing and ensure authentication and data integrity.
Edit named.conf and make the following changes:
After restarting BIND, the DNSSEC public and private keys are created and stored in the BIND base directory (/var/named
). Details of the public key will need to be added to the domain registrar to enable DNSSEC validation.
To retrieve the public key details, run:
Where:
21098
is the tag name;13
is the algorithm;2
is the hash mechanism;5E2B...FEA4
is the digest
Test DNSSEC validation using dig
. Look for the flag ad
to indicate authenticated data: