Gernot Walzl


The domain name system (DNS) resolves hostnames (e.g. to IP addresses.
BIND is the most used DNS server on the internet.

This tutorial shows how to configure a subdomain in BIND 9 on Debian 10 (buster).



The official Debian repository includes BIND 9:

apt install bind9


To run a name server for a subdomain,
the following records are relevant in the zone of the domain

sub      IN  NS  ; name server for subdomain
ns1.sub  IN  A             ; IPv4 address of
ns1.sub  IN  AAAA  2001:db8:10::1        ; IPv6 address of


The DNS server needs to accept incoming packages
on the following ports:


The zone file for needs to be specified in the configuration file:

zone "" {
    type master;
    file "/var/lib/bind/";


The zone file defines records for a (sub)domain.
Here is an exemplary zone file for the subdomain

$TTL  86400
@         IN  SOA (
                    2020042301    ; Serial  (YYYYMMDDxx)
                          3600    ; Refresh  (1 hour)
                           600    ; Retry  (10 mins)
                        604800    ; Expire  (7 days)
                          1800 )  ; Negative Cache TTL  (30 mins)

@         IN  NS
ns1       IN  A
ns1       IN  AAAA  2001:db8:10::1

; other hostnames
somehost  IN  A
another   IN  A

The content of the exemplary zone file means the following:


The following command reloads the configuration:

rndc reload


Install the dnsutils package:

apt install dnsutils

Verify that the DNS lookup returns the correct IP address:


Dynamic Updates

Updating the DNS records is useful when IP addresses are dynamically assigned.
For instance, DHCP servers automatically assign IP addresses to hosts.


The following command generates a random rndc key and
prints a configuration example to the terminal:


To allow a client to update the DNS records of with an rndc key,
enable it in the configuration file:

include "/etc/bind/rndc.key";

zone "" {
    type master;
    file "/var/lib/bind/";
    allow-update { key "rndc-key"; };


For updating DNS records, the following command line tool is used:


These commands update the IPv4 address of

key rndc-key C3...DQ==
update delete A
update add 86400 A
CONTENT.html source 2022-05-22 5.7 KB