(01)Install BIND DNS server
Linux
1# Ubuntu / Debian2sudo apt-get update3sudo apt-get install -y bind9 bind9utils bind9-doc4 5# RHEL / Fedora6sudo dnf install -y bind bind-utils7 8sudo systemctl enable named9sudo systemctl start namedConfigure BIND9 DNS server for internal and external name resolution
What is this?
DNS translates website names (like google.com) into IP addresses computers understand.
Where to create or edit the main configuration — paths below match the setup steps.
/etc/bind/named.confLocation: BIND DNS server
Zones and options
/var/named/*.zoneLocation: BIND zone files
DNS records for domains
Step 01
1# Ubuntu / Debian2sudo apt-get update3sudo apt-get install -y bind9 bind9utils bind9-doc4 5# RHEL / Fedora6sudo dnf install -y bind bind-utils7 8sudo systemctl enable named9sudo systemctl start namedStep 02
1sudo nano /etc/bind/named.conf.local2 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.com11 12# Example records:13# $TTL 8640014# @ 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.1017# www IN A 192.168.1.2018 19sudo named-checkconf20sudo named-checkzone example.com /etc/bind/db.example.com21sudo systemctl restart named1zone "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.1# Ubuntu — Netplan or resolv.conf2echo "nameserver 192.168.1.10" | sudo tee /etc/resolv.conf3 4# Test5dig @192.168.1.10 www.example.com6nslookup www.example.com 192.168.1.10Step 03
1dig @localhost example.com2dig @localhost www.example.com A3sudo journalctl -u named -fStep 04
1# Increment serial number in SOA when editing zone2sudo rndc reload example.com3sudo rndc status4 5# Flush cache6sudo rndc flush