In this blog post, we will cover the steps to set up monitoring for BIND DNS server using Prometheus Server and Grafana to visualize Bind metrics. BIND which stands for “Berkeley Internet Name Domain” is an open-source Domain Name server that allows you to publish your DNS information on the Internet and allow network users to do DNS queries.

The number of tools that can be used to monitor BIND DNS server is limited, and personally, I like Prometheus Bind exporter with Grafana. LibreNMS has BIND application monitoring that I was planning to give it a try.

Setup Pre-requisites

  1. Installed and configured BIND DNS server
  2. BIND need to have been build with libxml2 support. This can be confirmed using
# named -V | grep libxml2
using libxml2 version: 2.9.1

3. Installed Prometheus – Install Prometheus on Ubuntu / CentOS / Debian

Step 1: Install Bind Prometheus Exporter

Install wget

--- Ubuntu / Debian ---
$ sudo apt -y install wget

--- CentOS / Fedora ---
$ sudo yum -y install wget

Download the latest release of bind_exporter binary:

curl -s | grep browser_download_url | grep linux-amd64 |  cut -d '"' -f 4 | wget -qi -

This downloads a 64-bit binary release for Linux, for other operating systems, check the bind_exporter releases page.

Extract downloaded file.

tar xvf bind_exporter*.tar.gz

Move extracted binary file to /usr/local/bin directory:

cd bind_exporter-*/
sudo mv bind_exporter /usr/local/bin

Confirm installation by checking the version installed.

$ bind_exporter --version
bind_exporter, version 0.3.0 (branch: HEAD, revision: c34ff3d6b4817f42e74b2b05b3797cf99683b4a9)
  build user:       [email protected]
  build date:       20200109-18:54:09
  go version:       go1.12.14

You can print command options using bind_exporter --help

$ bind_exporter --help
Usage of bind_exporter: string
    	Path to Bind's pid file to export process information. (default "/run/named/")
  -bind.stats-groups value
    	Comma-separated list of statistics to collect. Available: [server, view, tasks] (default "server,view,tasks")
  -bind.stats-url string
    	HTTP XML API address of an Bind server. (default "http://localhost:8053/")
  -bind.stats-version string
    	BIND statistics version. Can be detected automatically. Available: [xml.v2, xml.v3, auto] (default "auto")
  -bind.timeout duration
    	Timeout for trying to get stats from Bind. (default 10s)
    	Print version information.
  -web.listen-address string
    	Address to listen on for web interface and telemetry. (default ":9119")
  -web.telemetry-path string
    	Path under which to expose metrics. (default "/metrics")

Step 2: Configure BIND DNS server

You need to configure BIND to open a statistics channel. Since the exporter and BIND are on the same host, the port is opened locally.

For CentOS ISC BIND DNS server, edit the file /etc/named.conf to add.

statistics-channels {
  inet port 8053 allow {; };

For Ubuntu / Debian ISC BIND DNS server, edit the file /etc/bind/named.conf.options

statistics-channels {
  inet port 8053 allow {; };

Restart bind for the changes to be effected

sudo systemctl restart named

Step 3: Create Bind Exporter systemd service

The next part is to create systemd service used to start the collector with access to the bind(named) pid file and enable the view stats group:

Add Prometheus system user account:

sudo groupadd --system prometheus
sudo useradd -s /sbin/nologin --system -g prometheus prometheus

This user will manage the exporter service. Once the user account has been added, create a systemd service unit file:

sudo tee /etc/systemd/system/bind_exporter.service<<EOF

ExecReload=/bin/kill -HUP $MAINPID
ExecStart=/usr/local/bin/bind_exporter \ \
  --bind.timeout=20s \
  --web.listen-address= \
  --web.telemetry-path=/metrics \
  --bind.stats-url=http://localhost:8053/ \



Reload systemd and start bind_exporter service:

sudo systemctl daemon-reload
sudo systemctl restart bind_exporter.service

Enable the service to start on boot:

sudo systemctl enable bind_exporter.service

Confirm that the service is listening on port 9153 as configured

$ sudo ss -tunelp | grep 9153
tcp    LISTEN     0      128      :::9153                 :::*                   users:(("bind_exporter",pid=23266,fd=3)) uid:997 ino:113951 sk:ffff8d17fab19980 v6only:0 <->

Open the port on the firewall if you have firewalld running:

sudo firewall-cmd --add-port=9153/tcp --permanent
sudo firewall-cmd --reload

Step 4: Configure Prometheus Server

If you don’t have a running Prometheus server, refer to our previous guide on how to Install Prometheus Server on CentOS and Ubuntu Linux. Below is a definition of my two jobs

- job_name: dns-master
      - targets: ['']
          alias: dns-master

  - job_name: dns-slave1
      - targets: ['']
          alias: dns-slave

Restart prometheus server:

sudo systemctl restart prometheus

Step 5: Add Grafana Dashboard

We’re going to use already created Grafana dashboard by Cristian Calin. Dashboard ID is 1666. Login to Grafana and Add Prometheus data source if you haven’t.

When Prometheus data source has been added, import Bind Grafana Dashboard by navigating to Dashboard > Import. Use 1666 for Grafana Dashboard ID.

grafana add prometheus dns dashboard min

Give it a descriptive name and choose Prometheus data source added earlier.

grafana add prometheus dns dashboard 02 min

Click “Import” button to start using the dashboard. After a few minutes, the metrics should start showing.

grafana dashboards min

Stay tuned for more monitoring guides with Prometheus and Grafana. Other monitoring guides are:

How to Monitor Linux Server Performance with Prometheus and Grafana in 5 minutes

How To Monitor Etcd Cluster with Prometheus and Grafana

How to Monitor Apache Web Server with Prometheus and Grafana in 5 minutes

Monitoring MySQL / MariaDB with Prometheus in five minutes

Your support is our everlasting motivation,
that cup of coffee is what keeps us going!

As we continue to grow, we would wish to reach and impact more people who visit and take advantage of the guides we have on our blog. This is a big task for us and we are so far extremely grateful for the kind people who have shown amazing support for our work over the time we have been online.

Thank You for your support as we work to give you the best of guides and articles. Click below to buy us a coffee.


Please enter your comment!
Please enter your name here