СHRISTMAS
WHEEL OF FORTUNE

Tap the button and win a guaranteed prize right now!

By registering, you are signing up to receiving e-mails.
JH
Joe Harris
September 19 2020
Updated June 7 2023

How to Configure BIND9 as a Primary DNS Server on Ubuntu 20.04

DNS Linux Ubuntu

You can use the DNS server in different ways. In this tutorial, we will configure BIND9 as the primary DNS server for a domain name. After that, you can specify the IP addresses of various domain services, for example, the mail server, as well as third-level domains.
Before you start, perform the installation and basic configuration of BIND9.

DNS zone creating

In this tutorial, we will use "domain-name.com" as an example. Symply change it to your domain name. Also, you need to use your real IP addresses instead of 10.1.1.xxx in the example.

Let’s add zone information to the configuration.

sudo nano /etc/bind/named.conf.local

Add these lines to it.

zone "domain-name.com" {
type master;
file "/etc/bind/db.domain-name.com";
allow-transfer { 10.1.1.10; };
also-notify { 10.1.1.10; };
};
  • type may be master, slave, forward, hint;
  • file - indicates the path to the new zone file;
  • allow-transfer - list of DNS servers that are allowed to transfer the zone;
  • also-notify - the primary DNS server will notify these servers of zone changes.

Restart the service.

systemctl reload bind9

Zone file configuration

Create a zone file from the template and open it.

sudo cp /etc/bind/db.local /etc/bind/db.domain-name.com
sudo nano /etc/bind/db.domain-name.com

Replace localhost in the SOA record with the FQDN of your server with the "." character at the end. In the example, this is "ns.domain-name.com.". Replace "root.localhost" with your valid admin email address with "." instead of "@" in it and "." at the end.
Serial - serial number of the change. You have to manually increment it every time you change the zone file. The secondary server monitors changes in the zone using this parameter.

;
;
;
$TTL    604800
@       IN      SOA     ns.domain-name.com. admin.domain-name.com. (
2        ; Serial
604800        ; Refresh
86400        ; Retry
2419200        ; Expire
604800 )      ; Negative Cache TTL
;
@       IN      NS      ns.domain-name.com.
@       IN      A       10.1.1.1
ns      IN      A       10.1.1.9
ns2     IN      A       10.1.1.10
mx      IN      A       10.1.1.15

The bottom of the file contains DNS records. The format of the record: hostname<tab>class<tab>DNS record type<tab>value. Where:

  • hostname - most often this value is a third-level domain name, and “domain-name.com” is filled in automatically. @ or none means an entry for the zone name (in this case, domain-name.com). You can also specify the FQDN with a dot at the end (for example, ns.domain-name.com.);
  • class is IN (Internet), indicates the type of network;
  • The most common types of DNS records: A, NS, MX, CNAME, TXT. "A" contains the IP address of the domain name, "NS" is the IP address of the zone's DNS server, "MX" - the mail server, "CNAME" - alias referring to the value of the specified record, "TXT" - custom entry;
  • value - IP address, host name, text information.

Restart the rndc.

sudo rndc reload

You can check the DNS server. Enter this command from any remote computer.

nslookup domain-name.com 10.1.1.9

Replace domain-name.com with your FQDN and 10.1.1.9 with the address of the newly configured name server. Your domain's DNS A-record will be used as the response. In the given example, this is 10.1.1.1.

Next step - BIND9 as a Secondary DNS Server.

Vote:
5 out of 5
Аverage rating : 5
Rated by: 2
33145 North Miami, FL 2520 Coral Way apt 2-135
+1 302 425-97-76
700 300
ITGLOBAL.COM CORP
700 300
We use cookies to make your experience on the Serverspace better. By continuing to browse our website, you agree to our
Use of Cookies and Privacy Policy.