“DNS is the phonebook of the internet, translating human-readable domain names into machine-readable IP addresses, enabling seamless connectivity across the globe.”
Install and Configure DNS Bind9 on Linux
Step 1: Install Bind9
Open a terminal and run the following command:
sudo apt update
sudo apt install bind9 bind9utils bind9-doc
Step 2: Configure Bind9
The primary configuration file for Bind9 is located at /etc/bind/named.conf.local
. Open this file to add your DNS zones.
sudo nano /etc/bind/named.conf.local
Add a Zone
Add the following lines for your zone configuration:
zone "example.com" {
type master;
file "/etc/bind/db.example.com";
};
Step 3: Create Zone File
Now create the zone file for your domain:
sudo nano /etc/bind/db.example.com
Add the following content to the zone file:
$TTL 604800
@ IN SOA ns.example.com. admin.example.com. (
2 ; Serial
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
604800 ) ; Negative Cache TTL
;
@ IN NS ns.example.com.
@ IN A 192.168.1.1
ns IN A 192.168.1.1
Step 4: Check Configuration
After configuration, check if there are any syntax errors:
sudo named-checkconf
Check the zone file:
sudo named-checkzone example.com /etc/bind/db.example.com
Step 5: Restart Bind9
sudo systemctl restart bind9
Step 6: Test Your DNS Server
Finally, you can test your DNS server using:
dig @localhost example.com
Learn More
To deepen your Linux knowledge, consider enrolling in the following course: