How to Setup DNS Server (Bind9) on Ubuntu 24.04 | Step-by-Step Guide

Опубликовано: 27 Декабрь 2025
на канале: LinuxTechi
7,234
83

Learn how to set up a powerful DNS server on Ubuntu 24.04 with Bind9, perfect for internal networks and custom domain resolution. This comprehensive step-by-step tutorial covers everything from installation to configuration and testing.

Steps Covered:

*1. Update System Packages*
Ensure your server is up-to-date before installation:
sudo apt update && sudo apt upgrade -y

*2. Install Bind9*
Install Bind9 along with utilities and documentation:
sudo apt install bind9 bind9utils bind9-doc -y

*3. Configure Bind9*
Edit the primary configuration file to define access control and DNS settings:

sudo vi /etc/bind/named.conf.options
Set up an internal network ACL and configure options such as forwarders, recursion, and query access.

acl internal-network {192.168.1.0/24;};
options {
directory "/var/cache/bind";
allow-query { localhost; internal-network; };
allow-transfer { localhost; };
forwarders { 8.8.8.8; };
recursion yes;
dnssec-validation auto;
listen-on-v6 { any; };};


Next, define your domain zones in `named.conf.local`:

sudo vi /etc/bind/named.conf.local
zone "linuxtechi.org" IN {
type master;
file "/etc/bind/forward.linuxtechi.org";
allow-update { none; };};
zone "1.168.192.in-addr.arpa" IN {
type master;
file "/etc/bind/reverse.linuxtechi.org";
allow-update { none; };};

Create forward and reverse zone files for internal domain resolution and IP mappings.

sudo vi forward.linuxtechi.org
$TTL 604800
@ IN SOA primary.linuxtechi.org. root.primary.linuxtechi.org. (
2022072651 ; Serial
3600 ; Refresh
1800 ; Retry
604800 ; Expire
604600 ) ; Negative Cache TTL
;Name Server Information
@ IN NS primary.linuxtechi.org.
;IP address of Your Domain Name Server(DNS)
primary IN A 192.168.1.40
;Mail Server MX (Mail exchanger) Record
linuxtechi.org. IN MX 10 mail.linuxtechi.org.
;A Record for Host names
www IN A 192.168.1.50
mail IN A 192.168.1.60
;CNAME Record
ftp IN CNAME www.linuxtechi.org.


sudo vi /etc/bind/reverse.linuxtechi.org


$TTL 86400
@ IN SOA linuxtechi.org. root.linuxtechi.org. (
2022072752 ;Serial
3600 ;Refresh
1800 ;Retry
604800 ;Expire
86400 ;Minimum TTL
)
;Your Name Server Info
@ IN NS primary.linuxtechi.org.
primary IN A 192.168.1.40
;Reverse Lookup for Your DNS Server
40 IN PTR primary.linuxtechi.org.
;PTR Record IP address to HostName
50 IN PTR www.linuxtechi.org.
60 IN PTR mail.linuxtechi.org.


Update `/etc/default/named` to ensure Bind listens on IPv4:
sudo vi /etc/default/named
Add `OPTIONS="-u bind -4"`

*4. Start and Enable the Bind Service*

Restart and enable Bind to apply changes:

sudo systemctl restart named

sudo systemctl enable named
sudo systemctl status named

Allow port 53 if your firewall is active:
sudo ufw allow 53

*5. Validate Bind Configuration and Zone Files*
Run syntax checks to verify Bind9 files:

sudo named-checkconf /etc/bind/named.conf.local
sudo named-checkzone linuxtechi.org /etc/bind/forward.linuxtechi.org
sudo named-checkzone linuxtechi.org /etc/bind/reverse.linuxtechi.org


*6. Test DNS Server Configuration*
Update `/etc/resolv.conf` on a client machine to test DNS resolution:

sudo vi /etc/resolv.conf

Set `search linuxtechi.org` and `nameserver 192.168.1.40`.

Test with `dig` and `nslookup` commands:
dig primary.linuxtechi.org
dig -x 192.168.1.40
nslookup www.linuxtechi.org

#howto #install #bind #dns #ubuntu24

If you have found this tutorial informative and useful, kindly do subscribe our channel and like the video.

Web Site : www.linuxtechi.com
YouTube Channel : https://www.youtube.com@linuxtechi9979