🌍
Networking & Server

DNS Server (BIND)

Configure BIND9 DNS server for internal and external name resolution

🐧 Linux🍎 Mac🪟 Windows
Reviewed: Tested on: Kubernetes 1.29 · Terraform 1.8 · Ubuntu 22.04

What is this?

DNS translates website names (like google.com) into IP addresses computers understand.

📁

Config files for DNS Server (BIND)

Where to create or edit the main configuration — paths below match the setup steps.

  • /etc/bind/named.conf

    Location: BIND DNS server

    Zones and options

  • /var/named/*.zone

    Location: BIND zone files

    DNS records for domains

📥

Step 01

Install BIND9

(01)Install BIND DNS server

Linux
1# Ubuntu / Debian
2sudo apt-get update
3sudo apt-get install -y bind9 bind9utils bind9-doc
4
5# RHEL / Fedora
6sudo dnf install -y bind bind-utils
7
8sudo systemctl enable named
9sudo systemctl start named
⚙️

Step 02

Configure DNS

(01)Forward zone (example.com)

Linux
1sudo nano /etc/bind/named.conf.local
2
3# Add zone block:
4zone "example.com" {
5 type master;
6 file "/etc/bind/db.example.com";
7};
8
9# Create zone file:
10sudo nano /etc/bind/db.example.com
11
12# Example records:
13# $TTL 86400
14# @ IN SOA ns1.example.com. admin.example.com. (2024010101 3600 1800 604800 86400)
15# @ IN NS ns1.example.com.
16# ns1 IN A 192.168.1.10
17# www IN A 192.168.1.20
18
19sudo named-checkconf
20sudo named-checkzone example.com /etc/bind/db.example.com
21sudo systemctl restart named

(02)Reverse zone (PTR records)

Linux
1zone "1.168.192.in-addr.arpa" {
2 type master;
3 file "/etc/bind/db.192";
4};
5
6# db.192:
7# 10 IN PTR ns1.example.com.
8# 20 IN PTR www.example.com.

(03)Configure client to use DNS server

Linux
1# Ubuntu — Netplan or resolv.conf
2echo "nameserver 192.168.1.10" | sudo tee /etc/resolv.conf
3
4# Test
5dig @192.168.1.10 www.example.com
6nslookup www.example.com 192.168.1.10

Step 03

Verify DNS

(01)Query and check logs

Linux
1dig @localhost example.com
2dig @localhost www.example.com A
3sudo journalctl -u named -f

Step 04

Manage DNS

(01)Add records and reload

Linux
1# Increment serial number in SOA when editing zone
2sudo rndc reload example.com
3sudo rndc status
4
5# Flush cache
6sudo rndc flush