Linux DNS Server Configuration

Linux DNS Server Configuration

Domain Name System (DNS) is an essential component of the internet that allows you to access websites using domain names instead of IP addresses. A DNS server translates domain names into IP addresses so that your computer can communicate with the requested website. In this article, we will guide you on how to configure a Linux DNS server.

Prerequisites:

  • A Linux system with root access
  • Basic knowledge of Linux commands

Step 1: Install BIND DNS Server

BIND (Berkeley Internet Name Domain) is the most widely used DNS server on the internet. To install BIND on your Linux system, run the following command:

sudo apt-get install bind9

Step 2: Configure BIND

The BIND configuration file is located at /etc/bind/named.conf. Open this file using a text editor and make the following changes:

  • Define the DNS server's IP address:
listen-on port 53 { 127.0.0.1; 192.168.0.10; };

Replace "192.168.0.10" with the IP address of your DNS server.

  • Allow recursive DNS queries:
recursion yes;
  • Set up a forwarder:
forwarders {
8.8.8.8;
8.8.4.4;
};

This will forward DNS queries to Google's public DNS servers. Replace these addresses with the IP addresses of your preferred DNS servers.

Step 3: Create DNS Zones

A DNS zone is a part of the DNS namespace that is managed by a specific DNS server. To create a zone, you need to define its domain name, DNS server, and DNS records.

Create a forward zone:

  • Create a zone file:
sudo nano /etc/bind/db.example.com

Replace "example.com" with your domain name.

  • Add the following content to the file:
$TTL 86400
@ IN SOA ns1.example.com. admin.example.com. (
2022042501 ; Serial
3600 ; Refresh
1800 ; Retry
604800 ; Expire
86400 ; Minimum TTL
)

@ IN NS ns1.example.com.
@ IN A 192.168.0.10
www IN A 192.168.0.11

This creates a DNS zone for "example.com" with two DNS records: one for the DNS server (ns1.example.com) and one for a website (www.example.com).

  • Add the zone to named.conf:
sudo nano /etc/bind/named.conf.local

Add the following content:

zone "example.com" {
type master;
file "/etc/bind/db.example.com";
};

Create a reverse zone:

  • Determine the reverse DNS zone for your network. For example, if your IP address range is 192.168.0.0/24, your reverse zone is 0.168.192.in-addr.arpa.
  • Create a zone file:
sudo nano /etc/bind/db.0.168.192
  • Add the following content to the file:
$TTL 86400
@ IN SOA ns1.example.com. admin.example.com. (
2022042501 ; Serial
3600 ; Refresh
1800 ; Retry
604800 ; Expire
86400 ; Minimum TTL
)

@ IN NS ns1.example.com.
10 IN PTR ns1.example.com.
11 IN PTR www.example.com.

This creates a reverse DNS zone for the IP addresses in the 192.

Related Searches and Questions asked:

  • Setting Up a Linux DNS Server on Ubuntu
  • Linux DNS Server List
  • What is the Best DNS for Linux?
  • What is an example of DNS server software?
  • That's it for this post. Keep practicing and have fun. Leave your comments if any.

    Post a Comment

    0 Comments