+
postgres
vue
+
mxnet
+
wasm
+
+
+
+
+
deno
weaviate
+
+
+
+
+
+
sql
windows
+
+
vb
+
+
+
lua
+
solidity
+
+
ada
groovy
+
+
travis
nuxt
abap
travis
+
+
+
+
+
+
mysql
bun
+
jax
grpc
+
android
zig
sql
keras
istio
+
+
*
+
+
remix
cdn
julia
sinatra
mocha
scheme
+
+
swc
terraform
+
cypress
+
+
intellij
+
+
bbedit
=>
+
echo
+
azure
hugging
+
erlang
Back to Blog
🌐 AlmaLinux DNS Server: Complete BIND Setup & Management Guide
AlmaLinux DNS BIND

🌐 AlmaLinux DNS Server: Complete BIND Setup & Management Guide

Published Sep 18, 2025

Master DNS servers on AlmaLinux! Learn BIND configuration, zone management, DNSSEC, caching, and troubleshooting. Complete guide with real-world examples.

55 min read
0 views
Table of Contents

🌐 AlmaLinux DNS Server: Complete BIND Setup & Management Guide

Hey there, DNS master! 🎉 Ready to control the internet’s phone book? Today we’re setting up BIND (Berkeley Internet Name Domain) on AlmaLinux – the most widely used DNS server that powers a huge portion of the internet! 🚀

Whether you’re managing domains for your company, creating a local DNS resolver, or learning how the internet really works, this guide will turn your AlmaLinux server into a DNS powerhouse! 💪

🤔 Why is Running a DNS Server Important?

Think of DNS as the internet’s GPS – without it, you’d have to remember IP addresses like 192.168.1.100 instead of domain names! 😱 Your own DNS server gives you complete control over name resolution!

Here’s why BIND on AlmaLinux is essential:

  • 🎯 Complete Control - Manage your own domains and records
  • Faster Resolution - Cache queries for lightning-fast responses
  • 🔒 Enhanced Security - DNSSEC support and access controls
  • 🌍 Custom Domains - Create any internal domains you want
  • 📊 Split-Horizon DNS - Different answers for internal/external queries
  • 🛡️ Privacy Protection - No DNS snooping by ISPs
  • 💼 Enterprise Features - Load balancing and failover
  • 🔄 Dynamic Updates - Automatic record updates

🎯 What You Need

Before we start building your DNS infrastructure, let’s check prerequisites:

AlmaLinux 9.x server (with static IP) ✅ Root or sudo access for configuration ✅ Basic networking knowledge (IPs, subnets) ✅ Domain name (optional, for authoritative setup) ✅ 2+ GB RAM for caching server ✅ Port 53 open (TCP and UDP) ✅ Backup DNS server (recommended) ✅ Coffee ready ☕ (DNS can be tricky!)

📝 Step 1: Install and Configure BIND

Let’s install BIND and set up the basics! 🎯

# Install BIND packages
sudo dnf install -y bind bind-utils

# Backup original configuration
sudo cp /etc/named.conf /etc/named.conf.backup

# Configure BIND main settings
sudo tee /etc/named.conf << 'EOF'
// BIND Configuration File

options {
    // Network settings
    listen-on port 53 { 127.0.0.1; 192.168.1.0/24; };
    listen-on-v6 port 53 { ::1; };

    // Directory paths
    directory "/var/named";
    dump-file "/var/named/data/cache_dump.db";
    statistics-file "/var/named/data/named_stats.txt";
    memstatistics-file "/var/named/data/named_mem_stats.txt";

    // Security settings
    allow-query { localhost; 192.168.1.0/24; };
    allow-transfer { none; };
    recursion yes;

    // DNSSEC validation
    dnssec-enable yes;
    dnssec-validation yes;

    // Forwarding (use Google DNS as backup)
    forwarders {
        8.8.8.8;
        8.8.4.4;
    };

    // Hide version
    version "DNS Server";

    // Cache settings
    max-cache-size 256M;
    max-cache-ttl 3600;
};

// Logging configuration
logging {
    channel default_log {
        file "/var/log/named/default.log" versions 3 size 5m;
        severity dynamic;
        print-time yes;
        print-severity yes;
        print-category yes;
    };

    channel queries_log {
        file "/var/log/named/queries.log" versions 3 size 10m;
        severity info;
        print-time yes;
    };

    category default { default_log; };
    category queries { queries_log; };
};

// Root hints
zone "." IN {
    type hint;
    file "named.ca";
};

// Include local zones
include "/etc/named.rfc1912.zones";
include "/etc/named.root.key";
include "/etc/named/zones.conf";
EOF

# Create log directory
sudo mkdir -p /var/log/named
sudo chown named:named /var/log/named

# Create zones configuration file
sudo tee /etc/named/zones.conf << 'EOF'
// Forward zone for example.local
zone "example.local" IN {
    type master;
    file "example.local.zone";
    allow-update { none; };
};

// Reverse zone for 192.168.1.0/24
zone "1.168.192.in-addr.arpa" IN {
    type master;
    file "192.168.1.rev";
    allow-update { none; };
};
EOF

Perfect! BIND is configured! 🎉

🔧 Step 2: Create DNS Zone Files

Now let’s create zone files for our domains:

# Create forward zone file
sudo tee /var/named/example.local.zone << 'EOF'
$TTL 86400
@   IN  SOA     ns1.example.local. admin.example.local. (
        2024010101  ; Serial
        3600        ; Refresh
        1800        ; Retry
        604800      ; Expire
        86400       ; Minimum TTL
)

; Name servers
    IN  NS      ns1.example.local.
    IN  NS      ns2.example.local.

; Name server A records
ns1 IN  A       192.168.1.10
ns2 IN  A       192.168.1.11

; A records for hosts
@       IN  A       192.168.1.10
www     IN  A       192.168.1.20
mail    IN  A       192.168.1.25
ftp     IN  A       192.168.1.30
db      IN  A       192.168.1.35

; CNAME records
webmail IN  CNAME   mail
portal  IN  CNAME   www

; MX records
@       IN  MX  10  mail.example.local.

; TXT records
@       IN  TXT     "v=spf1 mx -all"
EOF

# Create reverse zone file
sudo tee /var/named/192.168.1.rev << 'EOF'
$TTL 86400
@   IN  SOA     ns1.example.local. admin.example.local. (
        2024010101  ; Serial
        3600        ; Refresh
        1800        ; Retry
        604800      ; Expire
        86400       ; Minimum TTL
)

; Name servers
    IN  NS      ns1.example.local.
    IN  NS      ns2.example.local.

; PTR records
10  IN  PTR     ns1.example.local.
11  IN  PTR     ns2.example.local.
20  IN  PTR     www.example.local.
25  IN  PTR     mail.example.local.
30  IN  PTR     ftp.example.local.
35  IN  PTR     db.example.local.
EOF

# Set permissions
sudo chown root:named /var/named/*.zone
sudo chown root:named /var/named/*.rev
sudo chmod 640 /var/named/*.zone
sudo chmod 640 /var/named/*.rev

# Check configuration
sudo named-checkconf
sudo named-checkzone example.local /var/named/example.local.zone
sudo named-checkzone 1.168.192.in-addr.arpa /var/named/192.168.1.rev

Excellent! Zone files are created! 🌟

🌟 Step 3: Configure Firewall and Start Service

Let’s open the firewall and start our DNS server:

# Configure firewall
sudo firewall-cmd --permanent --add-service=dns
sudo firewall-cmd --reload

# Enable and start BIND
sudo systemctl enable named
sudo systemctl start named

# Check status
sudo systemctl status named

# Test DNS resolution
dig @localhost example.local
nslookup www.example.local localhost
host mail.example.local localhost

# Test reverse lookup
dig @localhost -x 192.168.1.20

✅ Step 4: Advanced DNS Features

Let’s add some advanced features to our DNS server:

# Create DNS management script
cat > /usr/local/bin/dns-manager.sh << 'EOF'
#!/bin/bash
# DNS Management Tool

add_a_record() {
    read -p "Domain: " DOMAIN
    read -p "Hostname: " HOST
    read -p "IP Address: " IP

    ZONE_FILE="/var/named/${DOMAIN}.zone"

    # Add A record
    echo "${HOST}    IN  A   ${IP}" >> $ZONE_FILE

    # Increment serial
    OLD_SERIAL=$(grep Serial $ZONE_FILE | awk '{print $1}')
    NEW_SERIAL=$((OLD_SERIAL + 1))
    sed -i "s/$OLD_SERIAL/$NEW_SERIAL/" $ZONE_FILE

    # Reload zone
    rndc reload $DOMAIN
    echo "✅ A record added: ${HOST}.${DOMAIN} -> ${IP}"
}

add_cname() {
    read -p "Domain: " DOMAIN
    read -p "Alias: " ALIAS
    read -p "Target: " TARGET

    ZONE_FILE="/var/named/${DOMAIN}.zone"

    # Add CNAME
    echo "${ALIAS}  IN  CNAME   ${TARGET}" >> $ZONE_FILE

    # Reload
    rndc reload $DOMAIN
    echo "✅ CNAME added: ${ALIAS}.${DOMAIN} -> ${TARGET}"
}

list_zones() {
    echo "📋 Configured Zones:"
    grep "^zone" /etc/named/zones.conf | awk '{print $2}' | tr -d '"'
}

check_dns() {
    read -p "Query: " QUERY
    echo "🔍 Checking $QUERY..."
    dig @localhost $QUERY +short
}

flush_cache() {
    rndc flush
    echo "✅ DNS cache flushed"
}

show_stats() {
    echo "📊 DNS Statistics:"
    rndc stats
    cat /var/named/data/named_stats.txt
}

case "$1" in
    add-a) add_a_record ;;
    add-cname) add_cname ;;
    list) list_zones ;;
    check) check_dns ;;
    flush) flush_cache ;;
    stats) show_stats ;;
    *) echo "Usage: $0 {add-a|add-cname|list|check|flush|stats}" ;;
esac
EOF

chmod +x /usr/local/bin/dns-manager.sh

🎮 Quick Examples

Example 1: Split-Horizon DNS

# Configure different views for internal/external
cat >> /etc/named.conf << 'EOF'

// Internal view
view "internal" {
    match-clients { 192.168.1.0/24; localhost; };

    zone "company.com" {
        type master;
        file "company.com.internal";
    };
};

// External view
view "external" {
    match-clients { any; };

    zone "company.com" {
        type master;
        file "company.com.external";
    };
};
EOF

Example 2: DNSSEC Configuration

# Generate DNSSEC keys
cd /var/named
dnssec-keygen -a RSASHA256 -b 2048 -n ZONE example.local
dnssec-keygen -a RSASHA256 -b 4096 -n ZONE -f KSK example.local

# Sign zone
dnssec-signzone -A -3 $(head -c 1000 /dev/random | sha1sum | cut -b 1-16) \
    -N INCREMENT -o example.local -t example.local.zone

Example 3: Dynamic DNS Updates

# Generate update key
tsig-keygen -a hmac-sha256 update-key

# Allow dynamic updates in zone
cat >> /etc/named/zones.conf << 'EOF'
zone "dynamic.local" {
    type master;
    file "dynamic.local.zone";
    allow-update { key update-key; };
};
EOF

# Update record dynamically
nsupdate -k update-key << EOF
server localhost
zone dynamic.local
update add test.dynamic.local 300 A 192.168.1.100
send
EOF

🚨 Fix Common Problems

Problem 1: DNS Not Resolving

# Check if BIND is running
sudo systemctl status named

# Check for errors
sudo journalctl -u named -n 50

# Verify configuration
sudo named-checkconf
sudo named-checkzone example.local /var/named/example.local.zone

# Test with dig
dig @localhost example.local

Problem 2: Slow DNS Queries

# Check cache effectiveness
rndc stats
grep "cache hit" /var/named/data/named_stats.txt

# Increase cache size
echo "max-cache-size 512M;" >> /etc/named.conf

# Check forwarders
dig @8.8.8.8 google.com

Problem 3: Zone Transfer Issues

# Allow specific servers
echo "allow-transfer { 192.168.1.11; };" >> /etc/named.conf

# Test zone transfer
dig @localhost example.local AXFR

📋 Simple Commands Summary

CommandPurpose
sudo systemctl status namedCheck BIND status
dig @localhost domain.comQuery DNS server
nslookup domain.com localhostLookup domain
rndc reloadReload configuration
rndc flushFlush DNS cache
rndc statsShow statistics
named-checkconfCheck configuration
named-checkzone zone fileValidate zone file

🏆 What You Learned

Congratulations! You’ve mastered DNS with BIND on AlmaLinux! 🎉

Installed and configured BIND DNS server ✅ Created zone files for forward and reverse lookups ✅ Set up caching for faster resolution ✅ Implemented security features ✅ Built management tools for DNS administration ✅ Learned advanced features like DNSSEC and dynamic updates

🎯 Why This Matters

Running your own DNS server gives you complete control over name resolution! 🌟 You can create custom domains, improve network performance, and enhance security! 🚀

Keep your DNS server updated and monitor it regularly for optimal performance! ⭐🙌