How to Configuring BIND as Private DNS on Ubuntu

Configuring BIND as Private DNS on Ubuntu

DNS servers play a critical role in network infrastructure, enabling the translation of domain names into IP addresses. One popular DNS server software is BIND (Berkeley Internet Name Domain), known for its robustness and versatility. In this comprehensive guide, we will walk you through the process of configuring BIND as a private network DNS server on Ubuntu. With step-by-step instructions, troubleshooting tips, and additional resources, you’ll be able to set up and manage your own DNS server with confidence.

Prerequisites and Installation

Before diving into the configuration process, let’s ensure that you have the necessary prerequisites in place and install Ubuntu and BIND on your server.

A. Hardware and Software Requirements:

To ensure optimal performance, it is recommended to meet the following requirements:

  1. Hardware Requirements:
  • A dedicated machine or virtual environment with sufficient resources (CPU, RAM, and storage) to handle DNS queries efficiently.
  • A reliable network connection for proper communication.
  1. Software Requirements:
  • Ubuntu Server: Install the latest version of Ubuntu Server on your machine or virtual environment.

B. Installing Ubuntu and BIND:

  1. Installing Ubuntu Server:
  • Download the latest Ubuntu Server ISO from the official Ubuntu website.
  • Follow the installation instructions, selecting the desired configuration options.
  • Once the installation is complete, ensure that the server is up-to-date with the latest security patches.
  1. Installing BIND:
  • Open a terminal on your Ubuntu server.
  • Update the package list by running the following command:
sudo apt update
  • Install BIND using the following command:
sudo apt install bind9

Configuring BIND for Private Network DNS

Now that you have Ubuntu and BIND installed, it’s time to configure BIND as a private network DNS server.

A. Understanding BIND Configuration Files:

Before proceeding, let’s familiarize ourselves with the key configuration files used by BIND:

  1. named.conf:
  • This file serves as the main configuration file for BIND.
  • It contains global options and references to other configuration files.
  1. named.conf.options:
  • This file specifies global options for BIND, including networking settings, logging options, and security configurations.

B. Setting Up Forwarding and Forwarders:

To resolve external DNS queries, we need to configure BIND to use forwarders. Follow these steps:

Open the named.conf.options file in a text editor:

sudo nano /etc/bind/named.conf.options

Locate the forwarders section and uncomment it by removing the “#” symbol:

forwarders {
    # your_forwarders_here;

Add the IP addresses of the DNS servers you want to use as forwarders within the curly braces. For example:

forwarders {;;

C. Creating a Zone File for the Private Network:

To configure BIND for your private network, you need to create a zone file. Follow these steps:

Create a new zone file in the /etc/bind directory:

sudo nano /etc/bind/

Define the zone by specifying the zone name and DNS server settings:

$TTL 86400
@       IN      SOA (
                        2023070101 ; Serial number (YYYYMMDDnn)
                        3600       ; Refresh interval
                        1800       ; Retry interval
                        604800     ; Expire interval
                        86400      ; Minimum TTL
@       IN      NS
ns1     IN      A

In the above example:

  • Replace with the hostname of your DNS server.
  • Replace with the email address of the administrator.
  • Replace with the IP address of your DNS server.

Add resource records (RR) for your private network. For example:

host1   IN      A
host2   IN      A

Replace host1 and host2 with the desired hostnames and corresponding IP addresses.

D. Configuring Zone Statements in named.conf:

To link the zone file with BIND, you need to configure zone statements in the named.conf file:

Open the named.conf file in a text editor:

sudo nano /etc/bind/named.conf

Locate the zone section and add a new zone statement for your private network:

zone "" {
    type master;
    file "/etc/bind/";

Replace with your desired domain name, and /etc/bind/ with the path to your zone file.

Testing and Troubleshooting

Now that the configuration is complete, it’s important to test and troubleshoot any potential issues.

A. Verifying BIND Configuration:

To check the syntax of your BIND configuration and detect any errors, use the named-checkconf command:

sudo named-checkconf

If there are no syntax errors, the command will return without any output. Otherwise, it will display the specific errors that need to be resolved.

B. Testing DNS Resolution:

To ensure proper DNS resolution within your private network, perform the following tests:

Test DNS resolution using dig:

  • Open a terminal on any client machine within your private network.
  • Run the following command, replacing with the hostname you defined in your zone file:

Test DNS resolution using nslookup:

  • Open a terminal on any client machine within your private network.
  • Run the following command, replacing with the hostname you defined in your zone file:

C. Monitoring and Logging:

To monitor BIND and troubleshoot any potential issues, it is crucial to enable logging:

Open the named.conf.options file in a text editor:

sudo nano /etc/bind/named.conf.options

Locate the logging section and uncomment it by removing the “#” symbol:

logging {
    # your_logging_options_here;

Configure the desired logging options based on your requirements.

For example, to log DNS queries and errors, you can add the following lines:

category queries { query_logging; };
category default { default_logging; };

Security Considerations

To ensure the security of your BIND DNS server, follow these best practices:

A. Securing BIND:

Implement Access Controls:

  • Restrict zone transfers to authorized DNS servers by specifying appropriate access controls in the named.conf file.
  • Use ACLs (Access Control Lists) to control which clients can query your DNS server.

Enable DNSSEC:

  • DNSSEC (Domain Name System Security Extensions) adds an extra layer of security to DNS by providing data integrity and authentication.
  • Configure DNSSEC for your private network by following the documentation provided by the Internet Systems Consortium (ISC), the organization behind BIND.

B. Firewall Configuration:

To protect your DNS server from unauthorized access, configure the firewall to allow DNS traffic (UDP and TCP):

  • Using iptables:

Set up iptables rules to allow DNS traffic on port 53.

For example, to allow incoming DNS queries, run the following command:

sudo iptables -A INPUT -p udp --dport 53 -j ACCEPT
  • Using ufw (Uncomplicated Firewall):

If you are using ufw, enable DNS traffic by running the following command:

sudo ufw allow 53/udp


Congratulations! You have successfully configured BIND as a private network DNS server on Ubuntu. By following this comprehensive guide, you now have a powerful DNS server at your disposal, enabling efficient domain name resolution within your private network. Remember to monitor your server, regularly update your configuration, and stay informed about the latest security practices.

Marshall Anthony is a professional Linux DevOps writer with a passion for technology and innovation. With over 8 years of experience in the industry, he has become a go-to expert for anyone looking to learn more about Linux.

Related Posts