BIND (Berkeley Internet Name Domain) is a widely used DNS server that plays a crucial role in the majority of name-serving machines on both intranets and the Internet.
This guide will walk you through the process of setting up an intranet DNS configuration using BIND on Linux, providing you with a fundamental understanding of Linux BIND DNS configuration.
Before we proceed, it’s important to note that this tutorial assumes you have already installed the Bind DNS server on your CentOS or RHEL system. If you haven’t done so, you can follow this guide on how to install Bind DNS server on CentOS and RHEL.
Configuring the BIND DNS Server
To begin, navigate to the directory where the BIND configuration file is located:
[root@server ~]# cd /var/named/chroot/etc
Open the configuration file named.conf:
[root@server etc]# vi named.conf
In the configuration file, you will need to specify the directory, pid-file, and forwarders. Here’s an example of what your configuration might look like:
options { directory "/etc"; pid-file "/var/run/named/named.pid"; forwarders { 202.188.0.133; 202.188.1.5; }; }; zone "myintranet.local" { type master; file "/var/named/myintranet.local.hosts"; }; zone "2.168.192.in-addr.arpa" { type master; notify no; file "/var/named/db.192"; };
Next, you will need to define the zones for your intranet. In this example, we’re setting up a zone for “myintranet.local” and a reverse lookup zone for “2.168.192.in-addr.arpa”. The configuration should look something like this:
zone "myintranet.local" { type master; file "/var/named/myintranet.local.hosts"; }; zone "2.168.192.in-addr.arpa" { type master; notify no; file "/var/named/db.192"; };
After saving and closing the named.conf file, navigate to the directory where the zone files are located:
[root@server ~]# cd /var/named/chroot/var/named
Open the zone file for “myintranet.local”:
[root@server named]# vi myintranet.local.hosts
In the zone file, you will need to specify the SOA (Start of Authority) record, NS (Name Server) record, and A (Address) records. Here’s an example of what your zone file might look like:
$ttl 38400 myintranet.local. IN SOA ns.myintranet.local. root.myintranet.local. ( 1298557357 10800 3600 604800 38400 ) myintranet.local. IN NS ns.myintranet.local. ns.myintranet.local. IN A 192.168.2.5 www.myintranet.local. IN A 192.168.2.5
Next, open the reverse lookup zone file:
[root@server named]# vi db.192
In the reverse lookup zone file, you will need to specify the SOA record, NS record, and PTR (Pointer) records. Here’s an example of what your reverse lookup zone file might look like:
$ttl 38400 2.168.192.in-addr.arpa. IN SOA ns.myintranet.local. root.myintranet.local. ( 1298557341 10800 3600 604800 38400 ) @ IN NS ns.myintranet.local. 5.2.168.192.in-addr.arpa. IN PTR ns.myintranet.local.
Starting the BIND DNS Server
After you’ve finished configuring the BIND DNS server, you can start the server with the following command:
[root@server /]# /etc/rc.d/init.d/named start
You should see a message indicating that the server has started successfully:
Starting named: [ OK ]
To ensure that the BIND DNS server starts automatically at boot time, use the following command:
[root@server /]# chkconfig named on
Testing the DNS Server
To verify that your DNS server is working correctly, you can use the nslookup command. However, before you do this, make sure that you have configured your DNS to 192.168.2.5.
Here’s an example of a successful nslookup result:
IP Address. . . . . . . . . . . . : 192.168.2.2 Subnet Mask . . . . . . . . . . . : 255.255.255.0 Default Gateway . . . . . . . . . : 192.168.2.1 DNS Servers . . . . . . . . . . . : 192.168.2.5 C:\>nslookup Default Server: ns.myintranet.local Address: 192.168.2.5 > myintranet.local Server: ns.myintranet.local Address: 192.168.2.5 Name: myintranet.local > www.myintranet.local Server: ns.myintranet.local Address: 192.168.2.5 Name: www.myintranet.local Address: 192.168.2.5 > ns.myintranet.local Server: ns.myintranet.local Address: 192.168.2.5 Name: ns.myintranet.local Address: 192.168.2.5 > exit
Commands Mentioned
- cd – Changes the current directory.
- vi – Opens a file in the vi text editor.
- /etc/rc.d/init.d/named start – Starts the BIND DNS server.
- chkconfig named on – Ensures that the BIND DNS server starts automatically at boot time.
- nslookup – Tests the DNS server.
Conclusion
Setting up and configuring a BIND DNS server on Linux can seem like a daunting task, but with the right guidance and understanding of the key concepts, it’s a task that can be accomplished by any dedicated server or VPS server administrator. This tutorial has provided a step-by-step guide to configuring a BIND DNS server for an intranet, including setting up the main configuration file, defining zones, and testing the server.
Remember, the key to successful server administration is understanding the underlying concepts and being able to apply them to your specific needs. Whether you’re working with a dedicated server, a VPS server, or even a cloud hosting or shared hosting environment, the principles remain the same.
For more in-depth information about web servers, you can check out these articles on the best web servers, Apache, Nginx, and LiteSpeed.
FAQ
-
What is BIND in Linux?
BIND, or Berkeley Internet Name Domain, is a widely used DNS server that plays a crucial role in the majority of name-serving machines on both intranets and the Internet. It is used to translate human-readable domain names into machine-readable IP addresses and vice versa.
-
What is the purpose of the named.conf file?
The named.conf file is the main configuration file for the BIND DNS server. It contains settings such as the location ofthe zone files, the types of zones, the IP addresses of forwarders, and other options that control the behavior of the BIND server.
-
What is a zone file in DNS?
A zone file in DNS is a text file that contains the details of a DNS zone – a portion of the DNS namespace. It includes records for each domain within the zone, such as A (Address) records, NS (Name Server) records, and PTR (Pointer) records.
-
What is the purpose of the nslookup command?
The nslookup command is used to query DNS servers to find the IP address associated with a domain name, or vice versa. It’s a useful tool for testing and troubleshooting DNS servers.
-
What does the chkconfig command do?
The chkconfig command is used in Linux to manage services and ensure they start automatically at boot time. In the context of this tutorial, the command “chkconfig named on” ensures that the BIND DNS server starts automatically whenever the system boots up.