DNS

  • DNS(Domain Name System) is a hierarchical system used to translate human-readable domain names (e.g., example.com) into their respective machine-readable IP addresses (e.g., 192.0.2.1).
  • In other words, a DNS Server resolves domain names into IP addresses and vice versa.

Structure/Components of DNS

  • DNS consists of several components:-
    • Zones and Domains:

      • A zone is an administrative segment of the DNS namespace.
      • A domain is a node in the DNS tree (e.g., example.com).
    • DNS Records: These include

      • A (Address): It maps a domain to an IPv4 address format.
      • AAAA (Address): It maps a domain to an IPv6 address format.
      • CNAME (Canonical Name): This is the alias name for another domain.
      • MX (Mail Exchange): It specifies mail servers for a domain.
      • NS (Name Server): It indicates authoritative name servers for a domain.
      • PTR (Pointer): It maps an IP address to a domain (reverse DNS).
      • SOA (Start of Authority): It defines zone properties and the primary server.

Types of DNS Servers

  • Authoritative DNS: This DNS stores and serves the DNS records for a domain.
  • Recursive DNS: This DNS resolves domain queries by iteratively contacting authoritative servers.
  • Caching DNS: This DNS temporarily stores query results to improve performance.

Configuring BIND (Berkeley Internet Name Domain)

  • BIND is one of the most commonly used DNS server software.
  • Here, BIND is applied for a domain such as ‘example.com’.

Installation

    • The BIND is installed using the package manager for the used Linux distribution. For example –
      • Debian/Ubuntu Linux :
        sudo apt update
        sudo apt install bind9 bind9utils bind9-doc
      • RHEL/CentOS Linux :
        sudo yum install bind bind-utils

Configuration Files

    • Primary Configuration File: /etc/bind/named.conf (Debian/Ubuntu) or /etc/named.conf (RHEL/CentOS).
    • Zone Files: Located in /var/named/ (RHEL/CentOS) or /etc/bind/ (Debian/Ubuntu).
    • Log Files: Usually found in /var/log/.

Basic Setup

    • To Edit the Main Configuration File:
      • To add zones in the main Configuration file(named.conf):
zone “example.com” {
    type master;
    file “/etc/bind/zones/db.example.com”;
};
    • To Create Zone Files:
      • To Create the directory for zone files:
sudo mkdir -p /etc/bind/zones
sudo nano /etc/bind/zones/db.example.com
    • Example Details of Zone File (db.example.com):
$TTL    86400
@       IN      SOA     ns1.example.com. admin.example.com. (
                        2025011901 ; Serial
                        3600       ; Refresh
                        1800       ; Retry
                        1209600    ; Expire
                        86400      ; Minimum TTL
)
@       IN      NS      ns1.example.com.
@       IN      A       192.0.2.1
ns1     IN      A       192.0.2.1
www   IN      A       192.0.2.2
    • Set File Permissions:
sudo chown bind:bind /etc/bind/zones/db.example.com
sudo chmod 640 /etc/bind/zones/db.example.com
    • Restart and Enable BIND:

sudo systemctl restart bind9       # Debian/Ubuntu
sudo systemctl restart named     # RHEL/CentOS
sudo systemctl enable bind9
    • Test Configuration:

      • The command named-checkconf is used to validate the configuration file and named-checkzone to verify the zone file:

        sudo named-checkconf
        sudo named-checkzone example.com /etc/bind/zones/db.example.com

Configuring a Caching DNS Server

  • A caching DNS server improves performance by storing previously queried results locally in their cache, reducing DNS lookup times.

Steps to Configure a Caching DNS Server:

    • Step1 : Install BIND

      • The BIND is installed using the package manager for the used Linux distribution. For example –
        • Debian/Ubuntu Linux :
sudo apt update
sudo apt install bind9 bind9utils bind9-doc
        • RHEL/CentOS Linux :
sudo yum install bind bind-utils
    • Step2 : Modify the Configuration:

      • Edit the main configuration file:
        sudo nano /etc/bind/named.conf.options  # Debian/Ubuntu
        sudo nano /etc/named.conf               # RHEL/CentOS
      • Configure forwarding and enable recursion:
options {
    directory “/var/cache/bind”;
    recursion yes;
    forwarders {
        8.8.8.8;  # Google Public DNS
        1.1.1.1;  # Cloudflare DNS
    };
    allow-query { any; };
};
    • Step3 : Restart the DNS Service:
sudo systemctl restart bind9  # Debian/Ubuntu
sudo systemctl restart named  # RHEL/CentOS
    • Step4 : Test the Caching Server:

      • The dig  command is used to query a domain and verify the response:
        dig example.com @127.0.0.1

Thus, the above setup provides a solid foundation for operating an authoritative or caching DNS server using BIND.

Summary of Commands Used in Configuring DNS

Tasks Command Used
 To Install BIND sudo apt install bind9 (Debian/Ubuntu)
To Restart BIND sudo systemctl restart bind9
To Check configuration syntax named-checkconf
To Verify zone files named-checkzone domain.com /path/to/zone
To Query DNS dig domain.com
To Test caching dig domain.com @127.0.0.1

Loading

Categories: Unix/Linux OS

0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.