DNS is a process where IP addresses are translated in to Host names or FULLY QUALIFIED DOMAIN NAME or FQDN. This is basically the address and the name of the server that you are wanting to broadcast or share to the outside world or your internal network. This is the way your place/server can be translated in to a readable location. I will try an guide you through the process.

1 – install your chosen OS (mine is Ubuntu Server 20.04.6)
2 – ssh <ip-address-here> into the VM/Server/SBC
3 – sudo apt update && sudo apt -y full-upgrade
note: Let’s reboot to get the changes to take affect.
4 – sudo reboot
note: Let’s install bind and it’s dependencies.
5 – sudo apt install -y bind9 bind9utils bind9-doc dnsutils
note: Move to the bind directory and copy the original config file to a .bak
6 – sudo cd /etc/bind
7 – sudo cp named.conf.options named.conf.options.bak
note: Let’s edit that file to our settings in
8 – sudo nano -c named.conf.options

acl trustedclients {
        localhost;
        localnets;
        172.16.18.0/24;
        172.16.19.0/24;
};

options {
        directory "/var/cache/bind";

        recursion yes;
        allow-query { trustedclients; };
        allow-query-cache { trustedclients; };
        allow-recursion { trustedclients; };

        forwarders {
                1.1.1.2;
                1.0.0.2;
        };

        dnssec-validation no;

        listen-on-v6 port 53 { ::1; };
        listen-on port 53 { 127.0.0.1; 172.16.17.10; };
};

note: Make sure you change the localnets & Listen on port 53 IP addy’s to the your ips in your network and server. Also Define your zone files – First backup the originals.
9 – sudo cp named.conf.local named.conf.local.bak
note: First we need to edit the named.conf.local file
10 – sudo nano -c named.conf.local
note: Make it look similar to the following

zone "domain.loc" {
        type master;
        file "/etc/bind/db.your_network.loc";
};

zone "17.16.172.in-addr.arpa" {
        type master;
        file "/etc/bind/db.172.16.17";
};

note:Let’s check to make sure there are no errors
11 – sudo named-checkconf
note: Now let’s create our forward lookup zone. Copy the existing original to a backup file.
12 – sudo cp db.local db.your_network.loc
note: now let’s edit the file and put our info in there.
13 – sudo nano -c db.your_network.lan
note: Make it look like what’s below

;
; BIND data file for templab.lan zone
;
$TTL    604800
@       IN      SOA     ns1.templab.lan. admin.templab.lan. (
                              3         ; Serial
                         604800         ; Refresh
                          86400         ; Retry
                        2419200         ; Expire
                         604800 )       ; Negative Cache TTL
;
@       IN      NS      ns1.templab.lan.

ns1     IN      A       172.16.17.10
dhcp1   IN      A       172.16.17.12
fw      IN      A       172.16.18.254

note: Check the Syntax
14 – sudo named-checkzone your_network.lan db.your_network.lan

note: Now we need to create a reverse lookup zone, also Let’s copy the existing one to our zone file.

15 – sudo cp db.127 db.172.16.17
note: Now edit the file
16 – sudo nano -c db.172.16.17
note: Copy and paste the following into the file and modify as you like.

;
; BIND reverse data file for templab.lan zone
;
$TTL    604800
@       IN      SOA     ns1.templab.lan. admin.templab.lan. (
                              2         ; Serial
                         604800         ; Refresh
                          86400         ; Retry
                        2419200         ; Expire
                         604800 )       ; Negative Cache TTL
;
@       IN      NS      ns1.templab.lan.

10      IN      PTR     ns1.templab.lan.
12      IN      PTR     dhcp1.templab.lan.

note: Check the Syntax again.
17 – sudo named-checkzone 17.16.172.in-addr.arpa db.172.16.17
note: make sure the dns is looking at itself to use DNS
18 – cd /etc/netplan
note: Edit the yaml file. fyi the number in front could be (50, 01, 00, 10)
19 – sudo nano 00-installer-config.yaml
note: Change the DNS Server Entry to this host’s IP address.
20 – sudo netplan apply
note: Start the DNS and then Test it also.
21 – sudo systemctl restart bind9
note: Let’s check the status of bind9.
22 – sudo systemctl status bind9
note: Test the DNS
23 – host pve-dns-vm-01.rpihobby.loc
24 – host ip_addy_here
25 – ping www.google.com

David McKone has a great video about this How To Install And Configure DNS Server In Linux.
Thank you for coming by and taking time to read our article. I hope you have a magnificent day.

By Michael Cooper

30 years in IT last 15 as a Senior Systems Engineer. GO BUCKS!

Leave a Reply

Your email address will not be published. Required fields are marked *