How To Set up Bind on AlmaLinux 9

This tutorial intends to show you How To Set up, Install, and Configure Bind on AlmaLinux 9.

BIND (Berkeley Internet Name Domain) is a software collection of tools including the world’s most widely used DNS (Domain Name System) server software. This feature-full implementation of DNS service and tools aims to be 100% standards-compliant and is; intended to serve as a reference architecture for DNS software.

BIND is the most commonly used DNS server software on the Internet. Typically, the people who manage BIND DNS servers day to day are network administrators or system administrators who are comfortable in Linux/UNIX. 

Steps To Set up Bind on AlmaLinux 9

To complete this guide, you must log in to your server as a non-root user with sudo privileges and set up a basic firewall. To do this, you can follow our guide on Initial Server Setup with AlmaLinux 9.

Also, you need a domain name that is pointed to your server’s IP address.

Install Bind on AlmaLinux 9

First, update the local package index with the following command:

sudo dnf update -y

Then, install Bind and bind-utils on AlmaLinux 9 with the following command:

sudo dnf install bind bind-utils -y

Start and Enable Bind Service

When your installation is finished, start the Bind service on AlmaLinux 9 with the command below:

systemctl start named

Then, enable it with the following command:

systemctl enable named

You can verify that your service is active and running with the following command:

systemctl status named
Output
● named.service - Berkeley Internet Name Domain (DNS)
     Loaded: loaded (/usr/lib/systemd/system/named.service; enabled; vendor pre>
     Active: active (running) since Thu 2023-01-05 05:36:46 EST; 9s ago
   Main PID: 71333 (named)
      Tasks: 6 (limit: 23609)
     Memory: 24.7M
        CPU: 130ms
     CGroup: /system.slice/named.service
....

Now let’s see how to configure Bind on AlmaLinux 9.

Configure Bind on AlmaLinux 9

First of all, you need to copy the Bind configuration file with the following command:

sudo cp /etc/named.conf  /etc/named.bak

Now open the file with your favorite text editor, here we use vi text editor:

sudo vi /etc/named.conf

Find the options section and comment on the two lines as shown below:

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

Then, find the allow-query parameter and adjust it according to your network subnet:

allow-query { localhost; 192.168.43.0/24; };

When you are done, save and close the file.

This setting allows only the hosts in the defined network to access the DNS server and not just any other host.

Define Forward Lookup DNS Zone

Forward lookup DNS zone stores the hostname ip address relationship. When queried, it gives the IP address of the host system using the hostname.

In contrast, the reverse DNS zone returns the Fully Qualified Domain Name (FQDN) of the server in relation to its IP address.

To define the reverse and forward lookup zones, copy and paste the following content at the Bind configuration file on AlmaLinux 9 with your own domain name:

sudo vi /etc/named.conf
//forward zone
zone "bind.orcacore.net" IN {
     type master;
     file "bind.orcacore.net.db";
     allow-update { none; };
     allow-query { any; };
};

//backward zone
zone "43.168.192.in-addr.arpa" IN {
     type master;
     file "bind.orcacore.net.rev";
     allow-update { none; };
     allow-query { any; };
};

Save and close the file, when you are finished.

For the rest of the configuring Bind on Almalinux 9, Let’s see how to create a forward DNS zone file for the domain.

Create a Forward DNS zone file on AlmaLinux 9

You can create a Forward DNS zone file for the domain with the following command:

sudo vi /var/named/bind.orcacore.net.db

Note: Remember to replace the domain name and hostname with your own.

Then, paste the following content into the file:

$TTL 86400
@ IN SOA hostname. admin.domain-name. (
                                                2020011800 ;Serial
                                                3600 ;Refresh
                                                1800 ;Retry
                                                604800 ;Expire
                                                86400 ;Minimum TTL
)

;Name Server Information
@ IN NS hostname.

;IP Address for Name Server
hostname IN A 192.168.43.35

;Mail Server MX (Mail exchanger) Record
domain-name. IN MX 10 mail.domain-name.

;A Record for the following Host name
www  IN   A   192.168.43.50
mail IN   A   192.168.43.60

;CNAME Record
ftp  IN   CNAME www.domain-name.

When you are finished, save and close the file.

Create a Reverse DNS zone file on AlmaLinux 9

For the rest of the configuring Bind on Almalinux 9, you need to create a reverse DNS zone file for the domain.

sudo vi /var/named/bind.orcacore.net.rev

Paste the following content into the file:

$TTL 86400
@ IN SOA hostname. admin.doaminname. (
                                            2020011800 ;Serial
                                            3600 ;Refresh
                                            1800 ;Retry
                                            604800 ;Expire
                                            86400 ;Minimum TTL
)
;Name Server Information
@ IN NS hostname.
hostname     IN      A       192.168.43.35

;Reverse lookup for Name Server
35 IN PTR hostname.

;PTR Record IP address to Hostname
50      IN      PTR     www.domainname
60      IN      PTR     mail.domainanme

When you are done, save and close the file.

Here you need to assign the necessary file permissions to the two configuration files with the following commands:

# sudo chown named:named /var/named/bind.orcacore.net.db
# sudo chown named:named /var/named/bind.orcacore.net.rev

Now verify the DNS zone lookup files have no syntax errors with the following commands:

# sudo named-checkconf
# sudo named-checkzone bind.orcacore.net /var/named/bind.orcacore.net.db
# sudo named-checkzone 192.168.43.35 /var/named/bind.orcacore.net.rev
Restart Bind service on AlmaLinux 9

To apply these changes run the following command:

sudo systemctl restart named
Configure Firewall

For client systems to access the system you need to add the DNS service on the firewall and thereafter reload the firewall. Execute the following commands:

# sudo firewall-cmd  --add-service=dns --zone=public  --permanent
# sudo firewall-cmd --reload

Test Bind from a Client system AlmaLinux 9

On a Client machine (Here our machine is AlmaLinux 9), open the /etc/resolv.conf file with your favorite text editor:

vi /etc/resolv.conf

Then edit the following parameter:

nameserver 192.168.43.35

When you are done, save and close the file.

Finally, you need to append the Bind DNS server’s IP address to the /etc/sysconfig/network-scripts/ifcfg-eth0 file as shown.

vi /etc/sysconfig/network-scripts/ifcfg-eth0

Then, Bind the DNS server’s IP address by adding this below the gateway:

...
DNS1= 192.168.43.35

Save and close the file, when you are finished.

Restart Network on AlmaLinux 9

To apply this change run the following command:

systemctl restart NetworkManager
Test Bind DNS Server

You can use the nslookup command or dig command to test the Bind DNS server on AlmaLinux 9.

nslookup 192.168.43.35
dig bind.orcacore.net

To perform a reverse DNS lookup you can use the following command:

dig -x 192.168.43.35

Also, on a windows client, you can open the internet protocol version 4 properties window and add the DNS server address:

Internet Protocol v4
IPv4

Conclusion

At this point, you have learned to Set up and Configure Bind on AlmaLinux 9. And you learned to test Bind on your Client system.

Hope you enjoy it.

You may be like these articles:

How To Install Yarn on AlmaLinux 9

How To Install PHP 8.2 on AlmaLinux 9

Install Python 3.11 on AlmaLinux 9

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Leave a Reply

Stay informed and not overwhelmed, subscribe now!