DNS or Domain Name System is a type of network service that every Linux administrator should be familiar with. This internet service acts like a phone book that resolves IP addresses like 192.168.1.1 to FQDNs (Fully Qualified Domain Names). Read the following article carefully to find out how to configure the DNS server on Ubuntu 22.04.
In order to make the configuration of the DNS server on Ubuntu 22.04, the first action is to install this server. Therefore, we recommend you choose the plan you need with the Ubuntu operating system from our Linux VPS server plans. We will use Bind DNS for this reason. Bind is a software that is open-source, scalable, and full-featured software suited for DNS services.
First of all, you should create a DNS domain for your site. (e.g. neuronvm.local)
– Neuronvm.local is the domain name
– ns.neuronvm.local is the DNS server name
– The IP address is 192.168.1.1
Tip 1: Here, the used IP address is just an example.
Tip 2: Make sure that your DNS server has a static IP address.
In this part, you will learn how to install a DNS server using Bind software. But first, you need to update your system using the following command:
sudo apt update
In this example, the package name is Bind9 and it is accessible in your base OS repository. Now, to update your system use the apt command below:
sudo apt install -y bind9 bind9-utils
The installation part was easy and simple.
The next part of your process is to make the configuration part. For this reason, you can use the /etc/bind/ directory that will hold configuration files and zone files. Also, /etc/bind/named.conf is the global configuration file for the DNS server.
You can apply the /etc/bind/named.conf.local directory and replace it with the global configuration file to create zones.
Here, we will show with the related command, how you can do this process:
sudo nano /etc/bind/named.conf.local
We will use the domain neuronvm.local for forward zone entry in the file named.conf.local. The role of this forward zone is to translate a fully qualified domain name into an IP address:
zone "neuronvm.local" IN { // Domain name
type master;
file "/etc/bind/neuronvm.local.db"; // Forward Zone file
allow-update { none; }; // Since this is the primary DNS, it should be none.
};
For the creation of a reverse name resolution zone in the named.conf.local file, you should go through the command below:
zone "0.168.192.in-addr.arpa" IN { // Reverse lookup name, should match your network in reverse order
type master;
file "/etc/bind/r.neuronvm.local.db"; // Reverse lookup file
allow-update { none; }; // Since this is the primary DNS, it should be none.
};
Now you should create zone files for your forward and reverse DNS zones.
– To create a forward DNS zone file /etc/bind/neuronvm.local.db, use the following command:
sudo nano /etc/bind/neuronvm.local.db
The record types :
SOA is the start of authority.
NS is the name server.
A is A record.
MX is mail for exchange.
CN is a canonical name.
Tip 1: Pay attention that domain names have to be ended with a dot (.).
Tip 2: As you want to change any record in your zone file, you should update the serial number of +1with the current number.
$TTL 86400
@ IN SOA ns.neuronvm.local.root.neuronvm.local.
200101 ; Serial
21600 ; Refresh
3600 ;
604800 ; Expire
86400 ) ; Negative Cache TTL
;
;Name Server Information
@ IN NS ns.neuronvm.local.
;IP address of Name Server
ns IN A 192.168.0.10
;Mail Exchanger
@ IN MX 10 mail.neuronvm.local.
;A – Record HostName To IP Address
www IN A 192.168.0.101
mail IN A 192.168.0.102
;CNAME record
ftp IN CNAME www.neuronvm.local.
– Now, for the creation of reverse DNS zone file /etc/bind/r.neuronvm.local.db, run this command:
sudo nano /etc/bind/r.neuronvm.local.db
Update the parts which are shown below:
PTR is the pointer.
SOA is the start of authority.
Tip 3: As you want to change any records in the lookup file, you should update the serial number +1 with the current number.
$TTL 86400
@ IN SOA ns.neuronvm.local.root.neuronvm.local.
200101 ; Serial
21600 ; Refresh
3600 ;
604800 ; Expire
86400 ) ; Negative Cache TTL
;
;Name Server Information
@ IN NS ns.neuronvm.local.
;Reverse lookup for Name Server
10 IN PTR ns.neuronvm.local.
;PTR Record IP address to HostName
101 IN PTR www.neuronvm.local.
102 IN PTR mail.neuronvm.local.
For checking any errors in the syntax of the DNS configuration file, apply this command:
sudo named-checkconf
If no error occurred, the command will return to the shell.
Use the command below to check the validation of the forward zone:
sudo named-checkzone neuronvm.local /etc/bind/neuronvm.local.db
Use the following command, to check the validation of the reverse zone:
sudo named-checkzone 0.168.192.in-addr.arpa /etc/bind/r.neuronvm.local.db
As the final step, you can reload both of the file zones. Also, you can use this command when you are willing to change the zone and zone file.
sudo rndc reload
If you want to verify the DNS server, you should run the dig command by looking up records.
dig www.neuronvm.local @192.168.1.1
For confirmation go through this way:
dig -x 192.168.1.11 @192.168.1.1
And at the end, you will be able to confirm that both lookup and reverse zones are working well.
By reading this article, you learned how you can install a DNS server on the Ubuntu operating system. Also, you learned how to create DNS and file zones and the way to confirm and verify both lookup and reverse zones. We hope you enjoy this tutorial.
Once you enabled private DNS, all of the DNS queries will be encrypted and will provide good safety for users.
Actually, DNS does not affect internet speed directly, but it can influence how fast a webpage appears on your system.
How useful was this post?
Click on a star to rate it!
Average rating 5 / 5. Vote count: 1
No votes so far! Be the first to rate this post.
This article is presented to review visual studio code or VSCode. This tool is a powerful open-sourc...
This article will help you to install Xubuntu on Vmware workstation. We recommend Xubuntu because of...
What is your opinion about this Blog?