In the last lecture, we saw how to register a domain name and set the authoritative DNS servers at 1
the register. If you want to host the domain on your own DNS server 2
the next step is to install and configure such a server. In this lecture will go over how to set up a 3
DNS server using the Bind version 9 software on Ubuntu. Bind or Berkeley Internet Name Domain is 4
an open source, flexible and full featured to DNS software that is widely used due to stability and 5
high quality. 6
Let's get started by installing the Bind 9 DNS server on the Ubuntu VPS that runs in the 7
DigitalOcean cloud. 8
I'm logging in to the server. 9
By the way, I have created an alias to login easier. 10
The name of the alias is VPs and this is the command. 11
I've changed to the port ssh listens on to 2299, so I'm just running 12
the alias. 13
And I'm in as root 14
So apt update 15
&& apt install bind9 bind9utils bind9-doc 16
It's installing the server. 17
It was installed! By default, Bind automatically starts after installation and to check if it's running 18
I'm executing systemctl status bind9. 19
It's running. 20
After installing Bind let’s set it to IPv4 mode since we are using only IPv4. If your network 21
uses IPv6 then set it to IPv6. I’m opening /etc/default/named 22
And we see some startup options for the server, like the user that runs the server. 23
I'm adding-4 to the end of the options parameter. 24
Here; if you wanted to offer IPV6 services, then add -6 instead of -4, -6 25
and -4 are mutually exclusive. 26
I'm saving and exiting the file. As with any other Linux server 27
we have to reload or restart for the changes to come into effect. 28
So systemctl reload-or-restart bind9 29
Now it runs as a local cache only DNS server. 30
To ask the server for an IP address I’m running: dig -t a @localhost and the domain google.com 31
So I'm sending the DNS query to the DNS server that's running on the localhost, and I want the address 32
-ta means type address for google.com. 33
If you want to ask another server write the IP address of that server instead of localhost, for 34
example, this is a public DNS server from CloudFlare. 35
And it returned another IP address because this domain has more IP addresses. 36
The next step is to configure the server. BIND configuration consists of multiple files, which are included 37
from the main configuration file. 38
This is the main configuration file of the server. 39
By the way, the name of the software is Bind Version 9, but the name of the process or deamon that's 40
running is named which comes from name daemon 41
ps -ef | grep named 42
This is the process that's running. 43
Let's take a look at the named.conf file and we see that there are three files that are included. 44
Name.conf.options contains the general server configuration options, like the interface 45
on which it listens, if it uses a forwarder or who is allowed to query the server; named.conf 46
.local contains the domains hosted on the server for which 47
it’s authoritative. 48
This is the file 49
where will add the information about our domain 50
crystalmind.academy; and the last filenamed.conf.default-zones contains information about 51
the root servers and default zones 52
like the localhost. 53
We don’t touch it too much! 54
Let’s dive deeper into DNS and see what types of DNS queries are available. DNS queries can be 55
classified according to the manner in which a complete request is processed, in recursive and iterative 56
queries. A recursive query is a kind of query in which the DNA server that received your query will 57
do all the job fetching the answer and giving it back to you. 58
During this process, the DNS server might also query other DNS servers on the Internet for the answer. 59
In the end, you'll get the final answer. 60
When you write in your browser the address of the website you want to visit, you are sending a recursive 61
query to the DNS server configured on the system. 62
This will do all the work behind the scenes to find out the ip address of that domain and get it back 63
to you. 64
What the server does behind the scenes is to find the answer from other DNS servers using some specific 65
steps. 66
The authoritative DNS servers for that domain are those that have the final information and send it 67
to the initial server. 68
We don't dive deeper into it for the moment. 69
Let's see instead what is an iterative or non recursive query. Tthe DNS name server will not go and 70
fetch the complete answer for our query, but will give you back a referral to other DNS servers, which 71
might have the answer. 72
Now it's your job to query those servers to find the answer. 73
Before diving into configuring Bind to host our domain, let's talk about DNS 74
forwarders. A forwarder is another DNS server that will be queried recursively by our server. 75
A DNS server configured to use at forwarder behaves as follows. 76
When the DNA server receives the query, it attempts to resolve the query by using the zone's hosted 77
locally or by using its cache. 78
If the query cannot be resolved using local data, the DNA server forwarderthe query recursively to the 79
DNS server that is designated as a forwarder. 80
If the forwarder is not available, the DNS server attempts to resolve the query by itself using iterative 81
queries. 82
So I'm adding to forwarders to our DNS server. In the option file 83
I'll set the public DNS servers of Google as forwarders for my server. 84
so vim/etc/bind/name.com.options 85
So before the closing curly brace I'm adding forwards 86
a pair of curly braces, a semicolon, and between the curly braces, I'm writing 8.8.8.8 87
semicolon and 8.8.4.4. semicolon. 88
These are the IP addresses of the forwarders. 89
So in just a few words, if the server doesn't know the DNS information asked by the clients, it will 90
send a recursive query to those two servers and wait for a final answer. 91
If it gets the answer, it will pass it to the client that has asked for it in the first place. 92
I'm saving the file and reloading the server. 93
I'm also checking its status; it's running. 94
Let's test the server. 95
I'm asking for the ip address of parrotlinux.org, so dig @localhost 96
I'm asking the server that's running on localhost -ta I want type address for parrotlinux.org 97
And these are the IP addresses of the domain; it's working. We have running DNS server on the local 98
machine. 99
By the way, Parrot Linux is a Linux distribution designed with security and privacy in mind. 100
We'll take a short break, and in the next lecture, we'll configure the DNS server as being authoritative 101
for our domain or to host it.