Primary Master DNS Server (Caching With Forwarder)
Primary Master DNS Server (Caching With Forwarder)
Introduction
Requirements
1. Operating System: Ubuntu 22.04.1 LTS
2. Privileged access to your Ubuntu System as root or via sudo command is
required
Outcomes
You will use a naming scheme that uses "dfn50303.com" to refer to our private subnet or
zone. By the end of this activity, you will have a primary DNS server with FQDN
ns.dfn50303.com and FQDN for each machine as shown below:
You are installing BIND package, modifying main configuration files and creating zones files
on the DNS server. Finally, you restart the bind9 (or named) service after the configuration
and zones files are properly verified.
1. On the DNS server, ns, update apt with root privileges by executing the following
command:
3. Check BIND9 service status. Type below command and press Enter;
bind9 service parameters file as following:
4. If the service is inactive (dead) you can start the service, type below command:
5. Save the changes on bind9 file and exit from the nano text editor.
6. With root privileges and using nano text editor, open the named.conf.options file
for editing:
7. In the named.conf.options file, above the existing options block, add a new ACL
block called "trusted". This is where you will define list of clients that we will allow
recursive DNS queries from:
acl "trusted" {
10.0.2.11;
10.0.2.12;
10.0.2.13;
10.0.2.14;
};
forwarders {
8.8.8.8;
8.8.4.4;
};
9. Save the named.conf.options file and exit from nano text editor.
10. Specify your DNS zones with root privileges and open the named.conf.local file
for editing:
zone "dfn50303.com" {
type master;
file "/etc/bind/zones/db.dfn50303.com";
};
12. As your private subnet is 10.0.2.0/24, specify the reverse zone as followings:
zone "2.0.10.in-addr.arpa" {
type master;
file "/etc/bind/zones/db.2.0.10";
};
13. Save the named.conf.local file and exit from nano text editor.
14. According to your named.conf.local configuration, that location should be
/etc/bind/zones. With root privileges, create the directory where your zone files
will reside:
15. Copy the sample db.empty zone file to the proper location with the following new
name:
16. Configure your forward zone file with root privileges and open the db.dfn50303.com
file for editing:
17. In the db.dfn50303.com file, change the SOA record by replacing the first
"localhost" with ns's FQDN, then replace "root.localhost" with
"admin.dfn50303.com". Also, every time you edit a zone file, you should increment
the serial value before you restart the named process, so, increment it to "3". It should
look as followings:
18. Then, delete the three records at the end of the file (after the SOA record).
19. At the end of the file, add your nameserver records with the following lines:
20. Then add the A records for your hosts that belong in this zone.
21. Save the db.dfn50303.com file and exit from nano text editor with
command control x.
22. Copy the sample db.empty zone file to the proper name and
location:
sudo cp /etc/bind/db.empty /etc/bind/zones/db.2.0.10
23. Configure your reverse zone file with root privileges and open the db.2.0.10 file for
editing:
24. Make changes on your reverse zone file and it looks like the following:
25. Save the db.2.0.10 file and exit from nano text editor.
26. Run the following command to check the syntax of the named.conf* files:
sudo named-checkconf
If your named configuration files have no syntax errors, you will return to your shell
prompt and see no error messages. If there are problems with your configuration
files, review the error message and the re-configure the related files, then try named-
checkconf again.
27. To check the correctness of your "dfn50303.com" forward zone configuration, run the
following command:
28. While, to check the "db.2.0.10.in-addr.arpa" reverse zone configuration, run the
following command:
When all your configuration and zone files have no errors in them, you should be
ready to restart the BIND service.
From the client machine, for instance file machine, you can test the DNS service provided
by ns machine using nslookup and dig utilities.
30. On file machine, update your network interface enp0s3 with the new DNS server
information as following:
.
.
nameservers:
addresses: [10.0.2.11]
31. You can perform a forward lookup to retrieve the IP address of www.dfn50303.com
by running the following command:
nslookup www.dfn50303.com
32. You can perform a forward lookup to retrieve the IP address of www.gnu.org by
running the following command:
nslookup www.gnu.org
Your DNS server support caching with a forwarder that will get all its information from
the forwarder. You have already set the fowarder to the Google Public DNS (IP: 8.8.8.8
and 8.8.4.4).
33. You can test the reverse lookup, query the DNS server with mail's private IP
address:
nslookup 10.0.2.14
34. You can also retrieve the IP address your local machines using dig command. All
you need to look at is the “ANSWER SECTION” of the dig command. To retrieve the IP
address of www.dfn50303.com:
dig www.dfn50303.com
35. Now, you can test connection with ping command to a local machine with its FQDN
instead of the IP address:
To view just the IP address of the www machine, use the short form option:
ping www.dfn50303.com
ping mail.dfn50303.com
DNS server may store previously resolved domain names to a local cache. By default the
cached records will be stored for seven (7) days. The cache can be reused for future domain
name resolutions.
37. To view cached dns records simply cat or grep the resulting dump file. For
example:
or,