How to Set Up a Full DNS Server in Red Hat Linux

Setting up a DNS server in Red Hat Linux allows you to manage domain names within your network, ensuring fast and reliable name resolution for internal and external services. Whether you need to create a custom internal domain, manage hostnames, or improve network performance, a dedicated DNS server simplifies IT management. This guide provides a step-by-step approach to setting up a DNS server. 1. Why Set Up a DNS Server? Custom domain management – Create internal domain names such as server.local instead of using IP addresses. Faster name resolution – Improves network efficiency by caching DNS queries. Better security – Controls access and prevents unauthorized DNS changes. Scalability – Handles large volumes of queries for enterprise environments. 2. Installing the DNS Server Package (BIND) BIND (Berkeley Internet Name Domain) is the most widely used DNS server software. Steps to Install BIND on Red Hat Linux Update the system: sudo yum update -y Install the BIND package: sudo yum install bind bind-utils -y Enable BIND to start on boot: sudo systemctl enable named Start the DNS service: sudo systemctl start named At this point, the DNS server is running. 3. Configuring the DNS Server Once installed, the next step is to set up DNS zones and define domain mappings. Step 1: Edit the Main Configuration File Open the BIND configuration file: sudo nano /etc/named.conf Modify or add the following settings: options { listen-on port 53 { 127.0.0.1; any; }; directory "/var/named"; allow-query { any; }; }; Save and exit (CTRL + X, then Y and Enter). Step 2: Define a Local DNS Zone Create a DNS zone file to manage domain names. Open the zone configuration file: sudo nano /etc/named.conf Add this entry under the zone section: zone "example.local" IN { type master; file "/var/named/example.local.zone"; }; Create the actual zone file: sudo nano /var/named/example.local.zone Add the DNS records: $TTL 86400 @ IN SOA ns1.example.local. admin.example.local. ( 2024042401 ; Serial 3600 ; Refresh 1800 ; Retry 604800 ; Expire 86400 ; Minimum TTL ) @ IN NS ns1.example.local. ns1 IN A 192.168.1.1 web IN A 192.168.1.10 Save and exit (CTRL + X, then Y and Enter). Step 3: Restart the DNS Service After configuring DNS settings, restart the BIND service to apply changes: sudo systemctl restart named 4. Testing the DNS Server Ensure the DNS server is responding correctly by running query tests. Check if the DNS Server Is Responding nslookup web.example.local 192.168.1.1 OR dig web.example.local @192.168.1.1 If the query returns the correct IP address, the DNS server is functioning as expected. Use Case: Setting Up an Internal DNS Server for a Company A company wants to simplify network operations by allowing employees to access servers using friendly names instead of numerical IP addresses. How an Internal DNS Server Helps: Easier Navigation – Employees can type database.local instead of memorizing IP addresses. Security Control – Restrict access to specific domain names based on user permissions. Performance Boost – Local DNS caching speeds up network lookups. Summary Setting up a DNS server in Red Hat Linux improves network management, security, and accessibility for internal services. Whether managing a business infrastructure or a home network, DNS provides efficient name resolution.

Apr 29, 2025 - 20:00
 0
How to Set Up a Full DNS Server in Red Hat Linux

Setting up a DNS server in Red Hat Linux allows you to manage domain names within your network, ensuring fast and reliable name resolution for internal and external services. Whether you need to create a custom internal domain, manage hostnames, or improve network performance, a dedicated DNS server simplifies IT management.

This guide provides a step-by-step approach to setting up a DNS server.

1. Why Set Up a DNS Server?

  • Custom domain management – Create internal domain names such as server.local instead of using IP addresses.
  • Faster name resolution – Improves network efficiency by caching DNS queries.
  • Better security – Controls access and prevents unauthorized DNS changes.
  • Scalability – Handles large volumes of queries for enterprise environments.

2. Installing the DNS Server Package (BIND)

BIND (Berkeley Internet Name Domain) is the most widely used DNS server software.

Steps to Install BIND on Red Hat Linux

  • Update the system:
   sudo yum update -y
  • Install the BIND package:
   sudo yum install bind bind-utils -y
  • Enable BIND to start on boot:
   sudo systemctl enable named
  • Start the DNS service:
   sudo systemctl start named

At this point, the DNS server is running.

3. Configuring the DNS Server

Once installed, the next step is to set up DNS zones and define domain mappings.

Step 1: Edit the Main Configuration File

Open the BIND configuration file:

sudo nano /etc/named.conf

Modify or add the following settings:

options {
    listen-on port 53 { 127.0.0.1; any; };
    directory "/var/named";
    allow-query { any; };
};

Save and exit (CTRL + X, then Y and Enter).

Step 2: Define a Local DNS Zone

Create a DNS zone file to manage domain names.

  • Open the zone configuration file:
   sudo nano /etc/named.conf
  • Add this entry under the zone section:
   zone "example.local" IN {
        type master;
        file "/var/named/example.local.zone";
   };
  • Create the actual zone file:
   sudo nano /var/named/example.local.zone
  • Add the DNS records:
   $TTL 86400
   @   IN  SOA  ns1.example.local. admin.example.local. (
               2024042401  ; Serial
               3600        ; Refresh
               1800        ; Retry
               604800      ; Expire
               86400       ; Minimum TTL
   )
   @   IN  NS   ns1.example.local.
   ns1 IN  A    192.168.1.1
   web IN  A    192.168.1.10
  • Save and exit (CTRL + X, then Y and Enter).

Step 3: Restart the DNS Service

After configuring DNS settings, restart the BIND service to apply changes:

sudo systemctl restart named

4. Testing the DNS Server

Ensure the DNS server is responding correctly by running query tests.

Check if the DNS Server Is Responding

nslookup web.example.local 192.168.1.1

OR

dig web.example.local @192.168.1.1

If the query returns the correct IP address, the DNS server is functioning as expected.

Use Case: Setting Up an Internal DNS Server for a Company

A company wants to simplify network operations by allowing employees to access servers using friendly names instead of numerical IP addresses.

How an Internal DNS Server Helps:

  • Easier Navigation – Employees can type database.local instead of memorizing IP addresses.
  • Security Control – Restrict access to specific domain names based on user permissions.
  • Performance Boost – Local DNS caching speeds up network lookups.

Summary

Setting up a DNS server in Red Hat Linux improves network management, security, and accessibility for internal services. Whether managing a business infrastructure or a home network, DNS provides efficient name resolution.