Domain Name System (DNS) is a fundamental component of the internet infrastructure that allows users to access websites and other online resources by converting human-readable domain names into IP addresses that computers can understand. BIND (Berkeley Internet Name Domain) is the most widely used DNS server software on the internet, and it is available for Linux-based operating systems such as Fedora.
In this blog, we will discuss how to configure and manage DNS services in Fedora with BIND. We assume that you have already installed Fedora and have root access to the system.
Step 1: Install BIND
The first step is to install BIND on your Fedora system. You can do this by running the following command as root:
dnf install bind bind-utils
This will install both the BIND DNS server and the BIND utilities, which we will need later on.
Step 2: Configure BIND
Once BIND is installed, the next step is to configure it. BIND configuration files are located in the /etc/named
directory. The main configuration file is named.conf.
By default, named.conf is empty, so we need to create a new configuration file for our DNS zone. For example, if we want to configure a DNS zone for the domain example.com, we would create a file named /etc/named/example.com.zone. This file should contain the following lines:
$TTL 86400
@ IN SOA ns1.example.com. admin.example.com. (
2023010101 ; serial number
3600 ; refresh
1800 ; retry
604800 ; expire
86400 ; minimum TTL
)
IN NS ns1.example.com.
IN NS ns2.example.com.
ns1 IN A 192.168.1.1
ns2 IN A 192.168.1.2
This configuration file defines a DNS zone for the example.com domain with two name servers (ns1.example.com and ns2.example.com) and their IP addresses. The $TTL
value is the default time-to-live value for records in the zone, which is set to 86400 seconds (one day) in this example.
Once you have created the zone file, you need to add it to the named.conf file by adding the following lines to it:
zone "example.com" IN {
type master;
file "/etc/named/example.com.zone";
};
This tells BIND to use the example.com.zone file as the configuration file for the example.com DNS zone.
Step 3: Start BIND
Once BIND is configured, you can start the DNS server by running the following command:
systemctl start named
You can check the status of BIND by running the following command:
systemctl status named
If BIND is running correctly, you should see output similar to the following:
● named.service - Berkeley Internet Name Domain (DNS)
Loaded: loaded (/usr/lib/systemd/system/named.service; enabled; vendor preset: disabled)
Active: active (running) since Mon 2023-03-15 10:00:00 EDT; 10s ago
Main PID: 1234 (named)
Tasks: 4 (limit: 11433)
Memory: 16.0M
CGroup: /system.slice/named.service
└─1234 /usr/sbin/named -u named -c /etc/named.conf
Step 4: Test DNS resolution
Once BIND is running, you can test DNS resolution by using the dig utility. For example, to test resolution for the example.com domain, run the following command:
dig example.com
If DNS resolution is working correctly, you should see output similar to the following:
; <<>> DiG 9.16.22-RedHat-9.16.22-1.fc35 <<>> example.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 12345
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 3
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
;; QUESTION SECTION:
;example.com. IN A
;; ANSWER SECTION:
example.com. 86400 IN A 192.168.1.3
;; AUTHORITY SECTION:
example.com. 86400 IN NS ns1.example.com.
example.com. 86400 IN NS ns2.example.com.
;; ADDITIONAL SECTION:
ns1.example.com. 86400 IN A 192.168.1.1
ns2.example.com. 86400 IN A 192.168.1.2
;; Query time: 0 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Mon Mar 15 10:00:00 EDT 2023
;; MSG SIZE rcvd: 123
This output shows that the DNS resolution was successful, and the IP address for the example.com domain is 192.168.1.3.
Step 5: Manage DNS records
To add or modify DNS records, you can edit the zone file for the appropriate DNS zone. For example, to add a new A record for the hostname www.example.com, you would add the following line to the example.com.zone file:
www IN A 192.168.1.4
Then, you would reload the DNS server configuration by running the following command:
systemctl reload named
After reloading the configuration, you can test the new record by running the dig command again:
dig www.example.com
If everything is working correctly, you should see the new A record in the ANSWER SECTION of the output.
Conclusion
In this blog, we have discussed how to configure and manage DNS services in Fedora with BIND. We covered the basic steps of installing BIND, configuring DNS zones, starting the DNS server, testing DNS resolution, and managing DNS records. With this knowledge, you should be able to set up and manage DNS services on your Fedora system using BIND.