APIE Camp #11 (October 2026) – DNS Configuration

Objectives

The goal of this lab is to set up a fully operational Domain Name System (DNS) with Recursive and Authoritative DNS Servers.

Setup

The configuration examples shown are based on the following setup:

DNS Server Fully Qualified Domain Name (FQDN) IPv4 Address IPv6 Address
Recursive   202.249.25.242 2001:D30:AF1E:8000::2
Primary Authoritative ns1.example.apiecamp.asia 202.249.25.243 2001:D30:AF1E:8000::3
Secondary Authoritative ns2.example.apiecamp.asia 202.249.25.244 2001:D30:AF1E:8000::4

Task 1: Install BIND for Three DNS Servers

  1. Install Berkeley Internet Name Domain (BIND) in all your name servers (one Recursive DNS Server and two Authoritative DNS Servers) using Ubuntu's package manager. Type your password if required by the sudo commands.

    • Navigate to home directory.

      cd ~
      
    • Update APT package index.

      sudo apt update
      
    • Install BIND and DNS utilities.

      sudo apt install -y bind9 bind9utils bind9-doc dnsutils
      

      This will install the latest stable version of BIND compiled for that operating system.
       

  2. Verify the installation.

    • Find the location where BIND or named is installed.

      which named
      
    • Check the version.

      named -v
      
    • Check whether BIND is running.

      sudo systemctl status named
      
      sudo systemctl status bind9
      
  3. Check the related files installed.

    ls -l /etc/bind
    
    ls -l /usr/share/dns
    
    ls -l /var/cache/bind
    
  4. Reconfigure BIND working directory and logging with the following steps.

    • Create the file for DNS logs and update the permissions.

      sudo mkdir /var/log/named
      
      sudo touch /var/log/named/bind.log
      
      sudo chown bind:bind -R /var/log/named
      
    • Navigate to /etc/bind and open named.conf.options file.

      cd /etc/bind/
      
      sudo nano named.conf.options
      
    • Find the directory section (usually in line# 2) and set it to /etc/bind as shown below:

      directory "/etc/bind";
      
    • Then add the following logging section at the end of the page:

      logging {
      	channel named_log {
      		file "/var/log/named/bind.log" versions 3 size 2m;
      		severity info;
      		print-severity yes;
      		print-time yes;
      		print-category yes;
      	};
      	category default { named_log; };
      	category config { named_log; };
      	category queries { named_log; };
      	category query-errors { named_log; };
      	category dnssec { named_log; };
      	category xfer-in { named_log; };
      	category xfer-out { named_log; };
      	category security { named_log; };
      };
      

      Use ctrl+o to save and press enter to confirm. And, press ctrl+x to exit.
       

  5. Change the owner to bind for the files in /etc/bind directory.

    sudo chown bind:bind -R /etc/bind
    
  6. Verify and apply configuration.

    • Check the configuration with named-checkconf whether there is any error. If there is no configuration error, it should NOT print any message (yes, no message means okay πŸ˜ƒ ).

      named-checkconf
      
    • If there's no error, restart BIND to apply the settings.

      sudo systemctl restart bind9
      
      sudo systemctl status bind9
      

      It should confirm that BIND is running.

      Active: active (running)
      
    • Then show the logs.

      sudo tail –f /var/log/named/bind.log
      

      The log should confirm that all zones are loaded and running.

      ==> /var/log/named/bind.log <==
      01-Apr-2026 03:32:55.307 zoneload: info: managed-keys-zone: loaded serial 2
      01-Apr-2026 03:32:55.307 zoneload: info: zone 0.in-addr.arpa/IN: loaded serial 1
      01-Apr-2026 03:32:55.307 zoneload: info: zone localhost/IN: loaded serial 2
      01-Apr-2026 03:32:55.311 zoneload: info: zone 127.in-addr.arpa/IN: loaded serial 1
      01-Apr-2026 03:32:55.311 zoneload: info: zone 255.in-addr.arpa/IN: loaded serial 1
      01-Apr-2026 03:32:55.311 general: notice: all zones loaded
      01-Apr-2026 03:32:55.319 general: notice: running
      
  7. Similar to systemctl, there is another utility called Remote Name Daemon Control (RNDC) that can be used to check and reconfigure BIND. This allows control of BIND without having to restart the service.

    • Check BIND status using RNDC.

      sudo rndc status
      

      Along with several other information, the last line should confirm if the server is running.

      server is up and running
      
    • Check the rndc.key file that was created during install. This is used by default if no other configuration or key file is specified.

      cd /etc/bind
      
      sudo more rndc.key
      
    • RNDC can be used to reload any configuration or zone files. You may need to use the commands in later sections but now it's just for your reference.

      • To reload configuration and zones.

        sudo rndc reload
        
      • To reload specified zone only.

        sudo rndc reload <zone-name>
        
      • To reload configuration and new zones only.

        sudo rndc reconfig
        

      You can also generate rndc.conf for more control on the allow list. We won’t be doing this in this lab.
       

  8. Permit DNS ports in your server's firewall (if any).

    sudo ufw allow 53/udp
    
    sudo ufw allow 53/tcp
    

STOP here and show the output to the instructors

Task 2: Configure Recursive DNS Server

  1. BIND comes with a very handy setup for the Recursive DNS Server when installed in Ubuntu/Debian. It has pretty much everything pre-configured with recursion enabled by default. However, for this lab, we will set recursion explicitly in the options statement.

    • Go to the /etc/bind directory and update the named.conf.options file.

      sudo nano named.conf.options
      
    • Just write the following line anywhere within the options statement:

      recursion yes;
      

      Use ctrl+o to save and press enter to confirm. And, press ctrl+x to exit.
       

  2. Apply the changes.

    • Reload zones and configurations.

      sudo rndc reload
      
      sudo rndc status
      
    • Alternatively, you can also restart BIND.

      sudo systemctl restart bind9
      
      sudo systemctl status bind9
      
    • If any error is encountered, check the logs and try to figure it out.

      sudo tail –f /var/log/named/bind.log
      

      or mention the number of lines that you want to read from the latest logs.

      sudo tail -20 /var/log/named/bind.log
      
  3. Use dig command to test the Recursive DNS Server. Take note of the ANSWER SECTION in the output.

    dig @127.0.0.1 academy.apnic.net
    
    dig @localhost www.apiecamp.asia
    
    dig +trace www.apiecamp.asia
    
    dig -x 133.27.114.27
    
    dig academy.apnic.net AAAA
    

STOP here and show the output to the instructors

Task 3: Configure Primary Authoritative DNS Server

  1. Add DNS zone for the domain in Primary Authoritative DNS Server.

    • Navigate to /etc/bind and open named.conf.local file.

      cd /etc/bind
      
      sudo nano named.conf.local
      
    • Add zone in the configuration file, and the zone type is primary or master.

      zone "example.apiecamp.asia." {
      	type primary;
      	file "/etc/bind/db.example.apiecamp.asia";
      };
      

    Use ctrl+o to save and press enter to confirm. And, press ctrl+x to exit.
     

  2. Check for any syntax errors in the configuration files or in the zone files.

    named-checkconf
    
  3. Create the zone file for your domain.

    sudo nano db.example.apiecamp.asia
    
    • Add necessary resource records.

      ;; Forward zone for example.apiecamp.asia.
      $ORIGIN example.apiecamp.asia.
      $TTL 300
      @		IN	SOA	ns1.example.apiecamp.asia. root.example.apiecamp.asia. (
      		2026040101	; Serial No.
      		1800		; Refresh
      		3600		; Retry
      		604800		; Expire
      		300		; Negative TTL 
      )
      		IN	NS	ns1.example.apiecamp.asia.
      
      ns1		IN	A	202.249.25.243
      		IN	AAAA	2001:D30:AF1E:8000::3
      ns2		IN	A	202.249.25.244
      		IN	AAAA	2001:D30:AF1E:8000::4
      www		IN	A	202.249.25.242
      		IN	AAAA	2001:D30:AF1E:8000::2
      mail1		IN	A	202.249.25.245
      		IN	AAAA	2001:D30:AF1E:8000::5
      mail2		IN	A	202.249.25.246
      		IN	AAAA	2001:D30:AF1E:8000::6
      @		IN	MX	10 mail1
      		IN	MX	20 mail2
      @		IN	TXT	"Example Authoritative DNS"
      

      Use ctrl+o to save and press enter to confirm. And, press ctrl+x to exit.
       

  4. Change the owner to bind for the files in /etc/bind/

    sudo chown bind:bind -R /etc/bind/
    
  5. Check for any syntax errors in the zone files.

    named-checkzone example.apiecamp.asia. /etc/bind/db.example.apiecamp.asia
    
  6. If you encounter any issues, check the logs.

    sudo tail –f /var/log/named/bind.log
    
  7. Reload zones and configurations to apply the changes.

    sudo rndc reload
    
    sudo rndc status
    
  8. Once BIND is running, go back to Recursive DNS Server and do some basic test using dig command.

    • To test your Authoritative DNS Server and display the SOA records for your domain.

      dig www.example.apiecamp.asia SOA +multi
      
    • To test your Authoritative DNS Server to display NS records.

      dig example.apiecamp.asia NS
      
    • To test your Authoritative DNS Server to display other resource records (A, MX, or TXT).

      dig ns1.example.apiecamp.asia A
      
      dig example.apiecamp.asia MX
      
      dig example.apiecamp.asia TXT
      

STOP here and show the output to the instructors

Task 4: Configure Secondary Authoritative DNS Server

  1. Add DNS zone for the domain in Secondary Authoritative DNS Server.

    • Navigate to /etc/bind and open named.conf.local file.

      cd /etc/bind
      
      sudo nano named.conf.local
      
    • Add zone in the configuration file, and the zone type is secondary or slave.

      zone "example.apiecamp.asia." {
      	type secondary;
      	primaries {
      		202.249.25.243;
      		2001:D30:AF1E:8000::3;
      	};
      	file "/var/cache/bind/db.example.apiecamp.asia";
      };
      

      Use ctrl+o to save and press enter to confirm. And, press ctrl+x to exit.
       

    In Ubuntu/Debian, /var/cache/bind is the default location for non-authoritative zones but you can change the directory with proper permission.
     

  2. Check for any syntax error.

    named-checkconf
    
  3. Add Secondary Authoritative Server's FQDN into the DNS zone configuration in Primary Authoritative DNS Server.

    • Edit the zone file.

      cd /etc/bind
      
      sudo nano db.example.apiecamp.asia
      
    • Add NS record for the Secondary Authoritative Server for the zone.

      ;; Forward zone for example.apiecamp.asia.
      $ORIGIN example.apiecamp.asia.
      $TTL 300
      @		IN	SOA	ns1.example.apiecamp.asia. root.example.apiecamp.asia. (
      		2026040102	; Serial No.
      		1800		; Refresh
      		3600		; Retry
      		604800		; Expire
      		300		; Negative TTL
      )
      		IN	NS	ns1.example.apiecamp.asia.
      		IN	NS	ns2.example.apiecamp.asia.
      
      ns1		IN	A	202.249.25.243
      		IN	AAAA	2001:D30:AF1E:8000::3
      ns2		IN	A	202.249.25.244
      		IN	AAAA	2001:D30:AF1E:8000::4
      -- (snipped) --
      

      Note: Do not forget to update the serial number in SOA record (usually by 1) every time you make any changes in your zone file. This is important for zone data synchronization. Failure to do so would result inconsistent name resolution.
       
      Use ctrl+o to save and press enter to confirm. And, press ctrl+x to exit.
       

  4. Check for any syntax errors in the zone files.

    named-checkzone example.apiecamp.asia. /etc/bind/db.example.apiecamp.asia
    
  5. Reload zones and configurations to apply the changes in Authoritative DNS Servers (both Primary and Secondary).

    sudo rndc reload
    
    sudo rndc status
    
  6. After configuration is completed. Check whether zone transfer occurs in the Secondary Authoritative DNS Server.

    • To manually do zone transfer, use this command:

      dig @202.249.25.243 example.apiecamp.asia. AXFR
      
    • You can also check the logs to see if transfer has been completed.

      sudo tail -20 /var/log/named/bind.log
      
      xfer-in: info: zone example.apiecamp.asia/IN: Transfer started.
      xfer-in: info: transfer of 'example.apiecamp.asia/IN' from 202.249.25.243#53:
      	connected using 202.249.25.243#53
      xfer-in: info: zone example.apiecamp.asia/IN: transferred serial 2026040102
      xfer-in: info: transfer of 'example.apiecamp.asia/IN' from 202.249.25.243#53:
      	Transfer status: success
      xfer-in: info: transfer of 'example.apiecamp.asia/IN' from 202.249.25.243#53:
      	Transfer completed: 1 messages, 17 records, 460 bytes, 0.001 secs
      	(460000 bytes/sec) (serial 2026040102)
      

STOP here and show the output to the instructors

Task 5: Configure Reverse DNS

5.1. IPv4 Reverse DNS

  1. Check the delegated IPv4 prefixes for your group. The reverse DNS zone is written in a special reverse order of the numbers in the prefixes. For instance, if you have been assigned with 202.249.25.240/28 for your group, let's consider the following situation:

    • APIE has received an IPv4 assignment of 202.249.25.128/25, hence the IPv4 reverse DNS zone would be written as 128/25.25.249.202.in-addr.arpa..
      • Octates have been repsented in reverse order.
    • APIE has further delegated each group with a /28 subnet. Hence, if a group is delegated with 202.249.25.240/28 by the parent zone 128/25.25.249.202.in-addr.arpa. that would mean that the group's reverse DNS zone would be 240/28.128/25.25.249.202.in-addr.arpa..
      • This may seem complicated in the first look, but if you follow the DNS hierarchy, it would make sense.
      • This is called "Classless IN-ADDR.ARPA delegation".
  2. In Primary Authoritative DNS Server, add the IPv4 reverse zone to the configuration file (named.conf.local).

    • Navigate to /etc/bind and open named.conf.local file.

      cd /etc/bind
      
      sudo nano named.conf.local
      
    • Add the following configuration.

      zone "240/28.128/25.25.249.202.in-addr.arpa." {
      	type primary;
      	file "/etc/bind/db.240S28.128S25.25.249.202.in-addr.arpa";
      };
      

      Use ctrl+o to save and press enter to confirm. And, press ctrl+x to exit.
       

    Actually db.240S28.128S25.25.249.202.in-addr.arpa above is just a chosen name.

    • "/" in the zone name has been replaced as β€œS” in the file name.
    • Because "/" is typically used for identifying directory path and therefore cannot be part of a file name.

    It does NOT necessarily need to look like that, you may choose any other name. It is not the syntax of a zone file.

    Reverse Zone Name:          240/28.128/25.25.249.202.in-addr.arpa.
    
    1. Remove trailing dot  ==> 240/28.128/25.25.249.202.in-addr.arpa
    2. Replace "/" with "S" ==> 240S28.128S25.25.249.202.in-addr.arpa
    3. Prepend "db."        ==> db.240S28.128S25.25.249.202.in-addr.arpa
    
  3. Check for any syntax error.

    named-checkconf
    
  4. Create a new zone file in /etc/bind/ directory. Remember, you need to use the same name that you have used in zone configuration above.

    • Create the zone file.

      cd /etc/bind
      
      sudo nano db.240S28.128S25.25.249.202.in-addr.arpa
      
    • Add necessary resource records.

      ;; Reverse DNS for 202.249.25.240/28
      $ORIGIN 240/28.128/25.25.249.202.in-addr.arpa.
      $TTL 300
      @		IN	SOA	ns1.example.apiecamp.asia. root.example.apiecamp.asia. (
      		2026040101	; Serial No.
      		1800		; Refresh
      		3600		; Retry
      		604800		; Expire
      		300		; Negative TTL
      )
      		IN	NS	ns1.example.apiecamp.asia.
      		IN	NS	ns2.example.apiecamp.asia.	
      
      242		IN	PTR	www.example.apiecamp.asia.
      243		IN	PTR	ns1.example.apiecamp.asia.
      244		IN	PTR	ns2.example.apiecamp.asia.
      245		IN	PTR	mail1.example.apiecamp.asia.
      246		IN	PTR	mail2.example.apiecamp.asia.
      

      Use ctrl+o to save and press enter to confirm. And, press ctrl+x to exit.
       

  5. Change the owner to bind for the files in /etc/bind/.

    sudo chown bind:bind -R /etc/bind/
    
  6. Check for any syntax errors in the zone files.

    named-checkzone 240/28.128/25.25.249.202.in-addr.arpa. \
    	/etc/bind/db.240S28.128S25.25.249.202.in-addr.arpa
    
  7. Configure Secondary Authoritative DNS Server to do zone transfer.

    • Navigate to /etc/bind and open named.conf.local file.

      cd /etc/bind
      
      sudo nano named.conf.local
      
    • Add zone in the configuration file, and the zone type is secondary or slave.

      zone "240/28.128/25.25.249.202.in-addr.arpa." {
      	type secondary;
      	primaries {
      		202.249.25.243;
      		2001:D30:AF1E:8000::3;
      	};
      	file "/var/cache/bind/db.128S28.128S25.25.249.202.in-addr.arpa";
      };
      

      Use ctrl+o to save and press enter to confirm. And, press ctrl+x to exit.
       

    • To manually do zone transfer, use this command:

      dig @202.249.25.243 240/28.128/25.25.249.202.in-addr.arpa. AXFR
      
  8. Reload zones and configurations to apply the changes in Authoritative DNS Servers (both Primary and Secondary).

    sudo rndc reload
    
    sudo rndc status
    
  9. You can check the logs to see if transfer has been completed.

    sudo tail -20 /var/log/named/bind.log
    
  10. Once BIND is running, run dig in Recursive DNS Server to validate the configuration.

    • Query from Primary Authoritative DNS Server.

      dig @ns1.example.apiecamp.asia 242.240/28.128/25.25.249.202.in-addr.arpa. PTR
      
    • Query from Secondary Authoritative DNS Server.

      dig @ns2.example.apiecamp.asia 242.240/28.128/25.25.249.202.in-addr.arpa. PTR
      
    • Query from the Internet.

      dig -x 202.249.25.242
      

STOP here and show the output to the instructors

5.2. Configure Reverse DNS for IPv6

  1. Similar to the steps above, create the reverse zone for the /52 IPv6 prefix. Again, the reverse DNS zone is written in a reverse order of the numbers in the prefixes. Let's consider the following example:

    IPv6 Prefix:                       2001:D30:AF1E:8000::/52
     
    1. Remove separator (colon)    ==> 20010D30AF1E8
    2. Add dot between hex numbers ==> 2.0.0.1.0.D.3.0.A.F.1.E.8
    3. Write in reverse order      ==> 8.E.1.F.A.0.3.D.0.1.0.0.2
    4. Append "ip6.arpa." domain   ==> 8.E.1.F.A.0.3.D.0.1.0.0.2.ip6.arpa.
    
  2. In Primary Authoritative DNS Server, add the IPv6 reverse zone to the configuration file (named.conf.local).

    • Navigate to /etc/bind and open named.conf.local file.

      cd /etc/bind
      
      sudo nano named.conf.local
      
    • Add the following configuration:

      zone "8.E.1.F.A.0.3.D.0.1.0.0.2.ip6.arpa." {
      	type primary;
      	file "/etc/bind/db.8.E.1.F.A.0.3.D.0.1.0.0.2.ip6.arpa";
      };
      

      Use ctrl+o to save and press enter to confirm. And, press ctrl+x to exit.
       

  3. Check for any syntax error.

    named-checkconf
    
  4. Populate reverse DNS zone for IPv6.

    • Create a corresponding zone file db.8.E.1.F.A.0.3.D.0.1.0.0.2.ip6.arpa.

      cd /etc/bind
      
      sudo nano db.8.E.1.F.A.0.3.D.0.1.0.0.2.ip6.arpa
      
    • Add necessary resource records.

      ;; Reverse DNS for 2001:D30:AF1E:8000::/52
      $ORIGIN 8.E.1.F.A.0.3.D.0.1.0.0.2.ip6.arpa.
      $TTL 300
      @		IN	SOA	ns1.example.apiecamp.asia. root.example.apiecamp.asia. (
      		2026040101	; Serial No.
      		1800		; Refresh
      		3600		; Retry
      		604800		; Expire
      		300		; Negative TTL
      )
      		IN	NS	ns1.example.apiecamp.asia.
      		IN	NS	ns2.example.apiecamp.asia.		
      
      ;; Prefix 2001:D30:AF1E:8000::/112
      $ORIGIN 0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.E.1.F.A.0.3.D.0.1.0.0.2.ip6.arpa.
      
      2.0.0.0		IN	PTR	www.example.apiecamp.asia.
      3.0.0.0		IN	PTR	ns1.example.apiecamp.asia.
      4.0.0.0		IN	PTR	ns2.example.apiecamp.asia.
      5.0.0.0		IN	PTR	mail1.example.apiecamp.asia.
      6.0.0.0		IN	PTR	mail2.example.apiecamp.asia.
      

      Use ctrl+o to save and press enter to confirm. And, press ctrl+x to exit.
       

  5. Change ownership of file.

    sudo chown bind:bind -R /etc/bind/
    
  6. Check if there's any syntax error.

    named-checkzone 8.E.1.F.A.0.3.D.0.1.0.0.2.ip6.arpa. \
        /etc/bind/db.8.E.1.F.A.0.3.D.0.1.0.0.2.ip6.arpa
    
  7. Configure Secondary Authoritative DNS Server to do zone transfer.

    • Navigate to /etc/bind and open named.conf.local file.

      cd /etc/bind
      
      sudo nano named.conf.local
      
    • Add zone in the configuration file, and the zone type is secondary or slave.

      zone "8.E.1.F.A.0.3.D.0.1.0.0.2.ip6.arpa." {
      	type secondary;
      	primaries {
      		202.249.25.243;
      		2001:D30:AF1E:8000::3;
      	};
      	file "/var/cache/bind/db.8.E.1.F.A.0.3.D.0.1.0.0.2.ip6.arpa";
      };
      

      Use ctrl+o to save and press enter to confirm. And, press ctrl+x to exit.
       

    • To manually do zone transfer, use this command:

      dig @202.249.25.243 8.E.1.F.A.0.3.D.0.1.0.0.2.ip6.arpa. AXFR
      
  8. Reload zones and configurations to apply the changes in Authoritative DNS Servers (both Primary and Secondary).

    sudo rndc reload
    
    sudo rndc status
    
  9. You can check the logs to see if transfer has been completed.

    sudo tail -20 /var/log/named/bind.log
    
  10. Once BIND is running, run dig in Recursive DNS Server to validate the configuration.

    • Query from Primary Authoritative DNS Server.

      dig @ns1.example.apiecamp.asia -x 2001:D30:AF1E:8000::2
      
    • Query from Secondary Authoritative DNS Server.

      dig @ns2.example.apiecamp.asia -x 2001:D30:AF1E:8000::2
      
    • Query from the Internet.

      dig -x 2001:D30:AF1E:8000::2
      

STOP here and show the output to the instructors

Task 6: Discussions about DNS Security

Nothing to do in the lab.

Task 7: Configure Access Control List (ACL)

  1. ACL for Recursive DNS: Configure ACL to allow queries from the class IP block only.

    • Navigate to /etc/bind and open named.conf.options file.

      cd /etc/bind
      
      sudo nano named.conf.options
      
    • Create an ACL by adding the following statement:

      acl localnet {
      	202.249.25.128/25;
      	2001:D30:AF1E::/48;
      	localhost;
      };
      

      Then update the options statement.

      allow-recursion { localnet; };
      allow-query { localnet; };
      allow-query-cache { localnet; };
      

      Use ctrl+o to save and press enter to confirm. And, press ctrl+x to exit.
       

    • Restart BIND and check the status.

      sudo systemctl restart bind9
      
      sudo systemctl status bind9
      
  2. ACL for Authoritative DNS Servers (both Primary and Secondary): Configure ACL to restrict queries to only authoritative zones and disable recursion.

    • Navigate to /etc/bind and open named.conf.options file.

      cd /etc/bind
      
      sudo nano named.conf.options
      
    • Update the options statements.

      recursion no;
      allow-query { any; };
      allow-query-cache { none; };
      

      Use ctrl+o to save and press enter to confirm. And, press ctrl+x to exit.
       

    • Restart BIND and check the status.

      sudo systemctl restart bind9
      
      sudo systemctl status bind9
      
  3. In your own laptop, open a terminal and use dig command to verify zone transfer.

    dig @202.249.25.243 example.apiecamp.asia. AXFR
    

    You can get a full copy of the zone, which is not secure.
     

  4. In the Primary Authoritative DNS Server, restrict who can get the zone file.

    • Navigate to /etc/bind and open named.conf.local file.

      cd /etc/bind/
      
      sudo nano named.conf.local
      
    • Add allow-transfer within the zone statement as below. Add Secondary Authoritative DNS Server's IP addresses.

      zone "example.apiecamp.asia." {
      	type primary;
      	file "/etc/bind/db.example.apiecamp.asia";
      	allow-transfer {
      		// These are the Secondary Authoritative DNS Server' addresses
      		202.249.25.244;
      		2001:D30:AF1E:8000::4;
      	};
      };
      
    • Check for any syntax error.

      named-checkconf
      
    • Restart BIND and check the status.

      sudo systemctl restart bind9
      
      sudo systemctl status bind9
      
  5. Verify that secure transfer works on Secondary Authoritative DNS Server.

    • Delete the zone file transferred previously.

      sudo rm /var/cache/bind/db.example.apiecamp.asia
      
    • Check for any syntax error.

      named-checkconf
      
    • Restart BIND and check the status.

      sudo systemctl restart bind9
      
      sudo systemctl status bind9
      
    • Check the log file to see the zone transfer.

      sudo tail -20 /var/log/named/bind.log
      
    • Also try to manually do zone transfer using dig command.

      dig @202.249.25.243 example.apiecamp.asia. AXFR
      

STOP here and show the output to the instructors

Task 8: Configure Transaction Signature (TSIG)

The following should be done in the Primary Authoritative DNS Server:

  1. Generate TSIG key to be used for authentication.

    • Navigate to /etc/bind and generate a new TSIG key.

      cd /etc/bind
      
      tsig-keygen -a hmac-sha256 ns1-ns2-tsig | sudo tee ns1-ns2-tsig.key
      
    • Check the contents of the file.

      sudo cat ns1-ns2-tsig.key
      
  2. Include TSIG key in the confiuguration.

    • Open named.conf.options file.

      sudo nano /etc/bind/named.conf.options
      
    • Add following include and server statements for the Secondary Authoritative DNS Server's addresses:

      include "/etc/bind/ns1-ns2-tsig.key";
      
      server 202.249.25.244 {
      	keys { ns1-ns2-tsig; };
      };
      
      server 2001:D30:AF1E:8000::4 {
      	keys { ns1-ns2-tsig; };
      };
      

      Use ctrl+o to save and press enter to confirm. And, press ctrl+x to exit.
       

  3. Change ownership of file.

    sudo chown bind:bind -R /etc/bind/
    
  4. Configure zone transfer to authentication based on key rather than IP addresses.

    • Open named.conf.local file.

      sudo nano /etc/bind/named.conf.local
      
    • Modify allow-transfer statement, remove the addresses and replace with key.

      allow-transfer {
      	//202.249.25.244;
      	//2001:D30:AF1E:8000::4;
      	key ns1-ns2-tsig;
      };
      

      Use ctrl+o to save and press enter to confirm. And, press ctrl+x to exit.
       

  5. Check for any syntax error.

    named-checkconf
    
  6. Restart BIND and check the status.

    sudo systemctl restart bind9
    
    sudo systemctl status bind9
    
  7. Send the key to the Secondary Authoritative DNS Server.

    sudo scp /etc/bind/ns1-ns2-tsig.key apie@202.249.25.244:/home/apie
    

The following should be done in the Secondary Authoritative DNS Server:

  1. Move the transferred key to the BIND working directory.

    sudo mv /home/apie/ns1-ns2-tsig.key /etc/bind
    
  2. Change ownership of the key file.

    sudo chown bind:bind -R /etc/bind/
    
  3. Enable key authentication.

    • Open named.conf.options file.

      sudo nano named.conf.options
      
    • Add following include and server statements for the Primary Authoritative DNS Server's addresses:

      include "/etc/bind/ns1-ns2-tsig.key";
      
      server 202.249.25.243 {
      	keys { ns1-ns2-tsig; };
      };
      
      server 2001:D30:AF1E:8000::3 {
      	keys { ns1-ns2-tsig; };
      };
      

      Use ctrl+o to save and press enter to confirm. And, press ctrl+x to exit.
       

  4. Restart BIND and check the status.

    sudo systemctl restart bind9
    
    sudo systemctl status bind9
    
  5. Verify zone transfer.

    • Try zone transfer without a key. This should result to Transfer failed.

      dig @202.249.25.243 example.apiecamp.asia. AXFR
      
    • Try zone transfer with a key. This should be successful.

      dig @202.249.25.243 example.apiecamp.asia. AXFR -k /etc/bind/ns1-ns2-tsig.key
      

Congratulations! You have reached the end of this lab.