earn how to set up and configure your own DNS server on Ubuntu Linux! Whether you're a system administrator or a Linux enthusiast, this tutorial will guide you through installing BIND9, configuring zone files, and verifying your setup — all in a clear, step-by-step manner.
🖥️ Step 01: BIND9 DNS server install (Ubuntu)
sudo apt update
sudo apt install bind9 bind9utils bind9-doc -y
________________________________________
📁 Step 02: Zone File configure
2.1: Zone define
sudo nano /etc/bind/named.conf.local
Add this line:
zone "mycompany.local" {
type master;
file "/etc/bind/zones/db.mycompany.local";
};
zone "40.120.10.in-addr.arpa" {
type master;
file "/etc/bind/zones/db.10.120.40";
};
________________________________________
2.2: Zone file create
sudo mkdir /etc/bind/zones
Forward Zone :
sudo cp /etc/bind/db.local /etc/bind/zones/db.mycompany.local
sudo nano /etc/bind/zones/db.mycompany.local
$TTL 604800
@ IN SOA ns1.mycompany.local. admin.mycompany.local. (
2 ; Serial
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
604800 ) ; Negative Cache TTL
@ IN NS ns1.mycompany.local.
ns1 IN A 10.120.40.80
www IN A 10.120.40.80
________________________________________
Reverse Zone :
sudo cp /etc/bind/db.127 /etc/bind/zones/db.10.120.40
sudo nano /etc/bind/zones/db.10.120.40
$TTL 604800
@ IN SOA ns1.mycompany.local. admin.mycompany.local. (
2 ; Serial
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
604800 ) ; Negative Cache TTL
@ IN NS ns1.mycompany.local.
80 IN PTR ns1.mycompany.local.
________________________________________
✅ Step 03: Configuration Check and service restart
1. sudo named-checkconf
2. sudo named-checkzone mycompany.local /etc/bind/zones/db.mycompany.local
3, sudo named-checkzone 40.120.10.in-addr.arpa /etc/bind/zones/db.10.120.40
Now restart bind
sudo systemctl restart bind9
sudo systemctl enable bind9
Step 4: Firewall Open (Ubuntu)
sudo ufw enable
sudo ufw allow 53/tcp
sudo ufw allow 53/udp
sudo ufw status
________________________________________
🧪 Step 5: Test DNS from Ubuntu
dig @localhost www.mycompany.local
nslookup www.mycompany.local 127.0.0.1
________________________________________
🖥️ Step 6: From Windows PC test DNS
5.1: DNS server IP Set:
1. Control Panel → Network and Sharing Center → Change adapter settings
2. Active connection → Right click → Properties
3. Internet Protocol Version 4 (TCP/IPv4) → Properties
4.
o Preferred DNS server: 10.120.40.80
________________________________________
5.2: Test on CMD
nslookup www.mycompany.local
ping www.mycompany.local