Este contenido no está disponible en el idioma seleccionado.
Chapter 2. Configuring zones on a BIND DNS server
To manage domain name resolution (DNS) for the example.com domain, configure a zone on a DNS BIND server. A DNS zone is a database with resource records for a specific sub-tree in the domain space. Therefore, clients can resolve www.example.com to the IP address configured in the zone.
2.1. The start of authority record in zone files Copiar enlaceEnlace copiado en el portapapeles!
To manage several DNS servers authoritative for a zone and DNS resolvers, you can use the start of authority (SOA) record. This record is essential in a DNS zone.
A SOA record in BIND has the following syntax:
name class type mname rname serial refresh retry expire minimum
name class type mname rname serial refresh retry expire minimum
For better readability, you need to split the record in zone files into several lines with comments that start with a semicolon (;). Note that, if you split a SOA record, parentheses keep the record together:
Note the trailing dot at the end of the fully-qualified domain name (FQDN). FQDN consists of several domain labels, separated by dots. Because the DNS root has an empty label, FQDN ends with a dot. Therefore, BIND appends the zone name to the names without a trailing dot.
A hostname without a trailing dot, for example, ns1.example.com expands to ns1.example.com.example.com., which is not the correct address of the primary name server.
These are the fields in a SOA record:
-
name: The name of the zone, the so-calledorigin. If you set this field to@, BIND expands it to the zone name defined in/etc/named.conf. -
class: In SOA records, you must set this field always to Internet (IN). -
type: In SOA records, you must set this field always toSOA. -
mname(master name): The hostname of the primary name server of this zone. -
rname(responsible name): The email address of who is responsible for this zone. Note that the format is different. You must replace the at sign (@) with a dot (.). serial: The version number of this zone file. Secondary name servers only update their copies of the zone if the serial number on the primary server is higher.The format can be any numeric value. A commonly-used format is
<year><month><day><two_digit_number>. With this format, you can, theoretically, change the zone file up to a hundred times per day.-
refresh: The amount of time secondary servers should wait before checking the primary server if the zone update is successful. -
retry: The amount of time after which a secondary server retries to query the primary server if the zone update is unsuccessful. -
expire: The amount of time after which a secondary server stops querying the primary server, if all earlier attempts failed. -
minimum: RFC 2308 changed the meaning of this field to the negative caching time. Compliant resolvers use it to decide how long to cacheNXDOMAINname errors.
A numeric value in the refresh, retry, expire, and minimum fields define a time in seconds. However, for better readability, use time suffixes, such as m for minute, h for hours, and d for days. For example, 3h stands for 3 hours.
2.2. Setting up a forward zone on a BIND primary server Copiar enlaceEnlace copiado en el portapapeles!
To enable mapping domain names to IP addresses and other information, set up a forward zone on a BIND primary server. For example, if you are responsible for the example.com domain, you can set up a forward zone in BIND to resolve names, such as www.example.com.
Prerequisites
-
You have installed the
bindpackage on the server. - You have configured the server to run as a caching name server.
-
The
namedornamed-chrootservice is running.
Procedure
Add a zone definition to the
/etc/named.conffile:Copy to Clipboard Copied! Toggle word wrap Toggle overflow These settings define:
-
This server is the primary server (
type master) for theexample.comzone. -
The
/var/named/example.com.zonefile is the zone file. If you set a relative path, as in this example, this path is relative to the directory you set indirectoryin theoptionsstatement. - Any host can query this zone. However, you can specify IP ranges or BIND access control list (ACL) nicknames to limit the access.
- No host can transfer the zone. Allow zone transfers only when you set up secondary servers and only for the IP addresses of the secondary servers.
-
This server is the primary server (
Verify the syntax of the
/etc/named.conffile:named-checkconf
# named-checkconfCopy to Clipboard Copied! Toggle word wrap Toggle overflow If the command displays no output, the syntax is correct.
Create the
/var/named/example.com.zonefile, for example, with the following content:Copy to Clipboard Copied! Toggle word wrap Toggle overflow This zone file:
-
Sets the default time-to-live (TTL) value for resource records to 8 hours. Without a time suffix, such as
hfor hour, BIND interprets the value as seconds. - Has the required Start of Authority (SOA) resource record with details about the zone.
-
Sets
ns1.example.comas an authoritative DNS server for this zone. To be functional, a zone requires at least one name server (NS) record. However, to be compliant with RFC 1912, you require at least two name servers. -
Sets
mail.example.comas the mail exchanger (MX) of theexample.comdomain. The numeric value in front of the hostname is the priority of the record. Entries with a lower value have a higher priority. -
Sets the IPv4 and IPv6 addresses of
www.example.com,mail.example.com, andns1.example.com.
-
Sets the default time-to-live (TTL) value for resource records to 8 hours. Without a time suffix, such as
Set secure permissions on the zone file that allow only the
namedgroup to read it:chown root:named /var/named/example.com.zone chmod 640 /var/named/example.com.zone
# chown root:named /var/named/example.com.zone # chmod 640 /var/named/example.com.zoneCopy to Clipboard Copied! Toggle word wrap Toggle overflow Verify the syntax of the
/var/named/example.com.zonefile:named-checkzone example.com /var/named/example.com.zone zone example.com/IN: loaded serial 2022070601 OK
# named-checkzone example.com /var/named/example.com.zone zone example.com/IN: loaded serial 2022070601 OKCopy to Clipboard Copied! Toggle word wrap Toggle overflow Reload BIND:
systemctl reload named
# systemctl reload namedCopy to Clipboard Copied! Toggle word wrap Toggle overflow If you run BIND in a change-root environment, use the
systemctl reload named-chrootcommand to reload the service.
Verification
Query different records from the
example.comzone, and verify that the output matches the records you have configured in the zone file:dig +short @localhost AAAA www.example.com
# dig +short @localhost AAAA www.example.comCopy to Clipboard Copied! Toggle word wrap Toggle overflow 2001:db8:1::30
2001:db8:1::30Copy to Clipboard Copied! Toggle word wrap Toggle overflow dig +short @localhost NS example.com
# dig +short @localhost NS example.comCopy to Clipboard Copied! Toggle word wrap Toggle overflow ns1.example.com
ns1.example.comCopy to Clipboard Copied! Toggle word wrap Toggle overflow dig +short @localhost A ns1.example.com
# dig +short @localhost A ns1.example.comCopy to Clipboard Copied! Toggle word wrap Toggle overflow 192.0.2.1
192.0.2.1Copy to Clipboard Copied! Toggle word wrap Toggle overflow This example assumes that BIND runs on the same host and responds to queries on the
localhostinterface.
2.3. Setting up a reverse zone on a BIND primary server Copiar enlaceEnlace copiado en el portapapeles!
To map IP addresses to names, you can set up a reverse zone on a BIND primary server. For example, if you have the 192.0.2.0/24 IP range, you can set up a reverse zone in BIND to resolve IP addresses from this range to hostnames.
If you create a reverse zone for classful IP addresses for a specific network, name the zone likewise. For example, for the class C network 192.0.2.0/24, the name of the zone is 2.0.192.in-addr.arpa. If you want to create a reverse zone for a different network size, for example 192.0.2.0/28, the name of the zone is 28-2.0.192.in-addr.arpa.
Prerequisites
- You have configured BIND as a caching name server.
-
The
namedornamed-chrootservice is running. - You have administrative privileges.
Procedure
Add a zone definition to the
/etc/named.conffile:Copy to Clipboard Copied! Toggle word wrap Toggle overflow These settings define:
-
This server is the primary server (
type master) for the2.0.192.in-addr.arpareverse zone. -
The
/var/named/2.0.192.in-addr.arpa.zonefile is the zone file. If you set a relative path, as in this example, this path is relative to the directory you set indirectoryin theoptionsstatement. - Any host can query this zone. However, you can specify IP ranges or BIND access control list (ACL) nicknames to limit the access.
- No host can transfer the zone. Allow zone transfers only when you set up secondary servers and only for the IP addresses of the secondary servers.
-
This server is the primary server (
Verify the syntax of the
/etc/named.conffile:named-checkconf
# named-checkconfCopy to Clipboard Copied! Toggle word wrap Toggle overflow If the command displays no output, the syntax is correct.
Create the
/var/named/2.0.192.in-addr.arpa.zonefile, for example, with the following content:Copy to Clipboard Copied! Toggle word wrap Toggle overflow This zone file:
-
Sets the default time-to-live (TTL) value for resource records to 8 hours. Without a time suffix, such as
hfor hour, BIND interprets the value as seconds. - Has the required Start of Authority (SOA) resource record with details about the zone.
-
Sets
ns1.example.comas an authoritative DNS server for this reverse zone. To be functional, a zone requires at least one name server (NS) record. However, to be compliant with RFC 1912, you require at least two name servers. -
Sets the pointer (
PTR) record for the192.0.2.1and192.0.2.30addresses.
-
Sets the default time-to-live (TTL) value for resource records to 8 hours. Without a time suffix, such as
Set secure permissions on the zone file that only allow the
namedgroup to read it:chown root:named /var/named/2.0.192.in-addr.arpa.zone chmod 640 /var/named/2.0.192.in-addr.arpa.zone
# chown root:named /var/named/2.0.192.in-addr.arpa.zone # chmod 640 /var/named/2.0.192.in-addr.arpa.zoneCopy to Clipboard Copied! Toggle word wrap Toggle overflow Verify the syntax of the
/var/named/2.0.192.in-addr.arpa.zonefile:named-checkzone 2.0.192.in-addr.arpa /var/named/2.0.192.in-addr.arpa.zone
# named-checkzone 2.0.192.in-addr.arpa /var/named/2.0.192.in-addr.arpa.zoneCopy to Clipboard Copied! Toggle word wrap Toggle overflow zone __2.0.192.in-addr.arpa/IN__: loaded serial __2022070601__ OK
zone __2.0.192.in-addr.arpa/IN__: loaded serial __2022070601__ OKCopy to Clipboard Copied! Toggle word wrap Toggle overflow Reload BIND:
systemctl reload named
# systemctl reload namedCopy to Clipboard Copied! Toggle word wrap Toggle overflow If you run BIND in a change-root environment, use the
systemctl reload named-chrootcommand to reload the service.
Verification
Query different records from the reverse zone, and verify that the output matches the records you have configured in the zone file:
dig +short @localhost -x 192.0.2.1
# dig +short @localhost -x 192.0.2.1Copy to Clipboard Copied! Toggle word wrap Toggle overflow ns1.example.com
ns1.example.comCopy to Clipboard Copied! Toggle word wrap Toggle overflow dig +short @localhost -x 192.0.2.30
# dig +short @localhost -x 192.0.2.30Copy to Clipboard Copied! Toggle word wrap Toggle overflow www.example.com
www.example.comCopy to Clipboard Copied! Toggle word wrap Toggle overflow This example assumes that BIND runs on the same host and responds to queries on the
localhostinterface.
2.4. Updating a BIND zone file Copiar enlaceEnlace copiado en el portapapeles!
To update several DNS servers authoritative for a zone, update a zone file only on the primary server. For example, if you change the IP address of a server, you need to update the zone file. Other DNS servers that store a copy of the zone receive the update through a zone transfer.
Prerequisites
- You have configured a zone.
-
You have started the
namedornamed-chrootservice. - You have administrative privileges.
Procedure
Optional: Identify the path to the zone file in the
/etc/named.conffile:Copy to Clipboard Copied! Toggle word wrap Toggle overflow You find the path to the zone file in the
filestatement in the zone’s definition. A relative path is relative to the directory set indirectoryin theoptionsstatement.Edit the zone file:
- Make the required changes.
Increment the serial number in the start of authority (SOA) record.
ImportantIf the serial number is equal to or lower than the former value, secondary servers will not update their copy of the zone.
Verify the syntax of the zone file:
named-checkzone example.com /var/named/example.com.zone
# named-checkzone example.com /var/named/example.com.zoneCopy to Clipboard Copied! Toggle word wrap Toggle overflow zone __example.com/IN__: loaded serial __2022062802__ OK
zone __example.com/IN__: loaded serial __2022062802__ OKCopy to Clipboard Copied! Toggle word wrap Toggle overflow Reload BIND:
systemctl reload named
# systemctl reload namedCopy to Clipboard Copied! Toggle word wrap Toggle overflow If you run BIND in a change-root environment, use the
systemctl reload named-chrootcommand to reload the service.
Verification
Query the record you have added, modified, or removed, for example:
dig +short @localhost A ns2.example.com
# dig +short @localhost A ns2.example.comCopy to Clipboard Copied! Toggle word wrap Toggle overflow 192.0.2.2
192.0.2.2Copy to Clipboard Copied! Toggle word wrap Toggle overflow This example assumes that BIND runs on the same host and responds to queries on the
localhostinterface.
2.5. DNSSEC zone signing using the automated key generation and zone maintenance features Copiar enlaceEnlace copiado en el portapapeles!
To ensure authenticity of zone information for clients, you can sign zones with Domain Name System Security Extensions (DNSSEC). Signed zones contain additional resource records.
For enabling external DNS servers to verify the authenticity of a zone, add the public key of the zone to the parent zone. Contact your domain provider or registry for further details.
After enabling the DNSSEC policy feature for a zone, BIND automatically performs actions. It includes creating the keys, signing the zone, and maintaining the zone, including re-signing and periodically replacing the keys. In BIND, you can use the built-in default DNSSEC policy, which uses single ECDSAP256SHA key signatures. However, create your own policy to use custom keys, algorithms, and timings.
Prerequisites
-
You have installed the
bindpackage on the server. - You have configured the zone for which you want to enable DNSSEC.
-
The
namedornamed-chrootservice is running. - You have configured the server to synchronize the time with a time server. Always check for the correct system time before enabling DNSSEC validation.
Procedure
Add the
dnssec-policy default;andinline-signing yes;in the/etc/named.conffile to enable DNSSEC for the zone:zone "example.com" { ... dnssec-policy default; inline-signing yes; };zone "example.com" { ... dnssec-policy default; inline-signing yes; };Copy to Clipboard Copied! Toggle word wrap Toggle overflow Reload BIND:
systemctl reload named
# systemctl reload namedCopy to Clipboard Copied! Toggle word wrap Toggle overflow If you run BIND in a change-root environment, use the
systemctl reload named-chrootcommand to reload the service.BIND stores the public key in the
/var/named/K<zone_name>.+<algorithm>+<key_ID>.keyfile. Use this file to display the public key of the zone in the format that the parent zone requires:DS record format:
dnssec-dsfromkey /var/named/Kexample.com.+013+61141.key
# dnssec-dsfromkey /var/named/Kexample.com.+013+61141.keyCopy to Clipboard Copied! Toggle word wrap Toggle overflow example.com. IN DS 61141 13 2 3E184188CF6D2521EDFDC3F07CFEE8D0195AACBD85E68BAE0620F638B4B1B027
example.com. IN DS 61141 13 2 3E184188CF6D2521EDFDC3F07CFEE8D0195AACBD85E68BAE0620F638B4B1B027Copy to Clipboard Copied! Toggle word wrap Toggle overflow DNSKEY format:
grep DNSKEY /var/named/Kexample.com.+013+61141.key
# grep DNSKEY /var/named/Kexample.com.+013+61141.keyCopy to Clipboard Copied! Toggle word wrap Toggle overflow example.com. 3600 IN DNSKEY 257 3 13 sjzT3jNEp120aSO4mPEHHSkReHUf7AABNnT8hNRTzD5cKMQSjDJin2I3 5CaKVcWO1pm+HltxUEt+X9dfp8OZkg==
example.com. 3600 IN DNSKEY 257 3 13 sjzT3jNEp120aSO4mPEHHSkReHUf7AABNnT8hNRTzD5cKMQSjDJin2I3 5CaKVcWO1pm+HltxUEt+X9dfp8OZkg==Copy to Clipboard Copied! Toggle word wrap Toggle overflow
- Request to add the public key of the zone to the parent zone. Contact your domain provider or registry for further details on how to do this.
Verification
Query your own DNS server for a record from the zone for which you enabled DNSSEC signing:
dig +dnssec +short @localhost A www.example.com
# dig +dnssec +short @localhost A www.example.comCopy to Clipboard Copied! Toggle word wrap Toggle overflow 192.0.2.30 A 13 3 28800 20220718081258 20220705120353 61141 example.com. e7Cfh6GuOBMAWsgsHSVTPh+JJSOI/Y6zctzIuqIU1JqEgOOAfL/Qz474 M0sgi54m1Kmnr2ANBKJN9uvOs5eXYw==
192.0.2.30 A 13 3 28800 20220718081258 20220705120353 61141 example.com. e7Cfh6GuOBMAWsgsHSVTPh+JJSOI/Y6zctzIuqIU1JqEgOOAfL/Qz474 M0sgi54m1Kmnr2ANBKJN9uvOs5eXYw==Copy to Clipboard Copied! Toggle word wrap Toggle overflow This example assumes that BIND runs on the same host and responds to queries on the
localhostinterface.After the server adds the public key to the parent zone and propagates it to other servers, verify that the server sets the authenticated data (
ad) flag on queries to the signed zone:dig @localhost example.com +dnssec
# dig @localhost example.com +dnssecCopy to Clipboard Copied! Toggle word wrap Toggle overflow ... ;; flags: qr rd ra **ad**; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1 ...
... ;; flags: qr rd ra **ad**; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1 ...Copy to Clipboard Copied! Toggle word wrap Toggle overflow
2.6. Configuring zone transfers among BIND DNS servers Copiar enlaceEnlace copiado en el portapapeles!
To ensure that all DNS servers that have a copy of the zone to have up-to-date data, configure zone transfers among BIND DNS servers.
Prerequisites
- You have the administrative privileges.
- On the future primary server, the zone for which you want to set up zone transfers is already configured.
- On the future secondary server, BIND is already configured as a caching name server.
-
On both servers, the
namedornamed-chrootservice is running.
Procedure
On the existing primary server:
Generate a shared key and append it to the
/etc/named.conffile:tsig-keygen example-transfer-key | tee -a /etc/named.conf
# tsig-keygen example-transfer-key | tee -a /etc/named.confCopy to Clipboard Copied! Toggle word wrap Toggle overflow key "__example-transfer-key__" { algorithm hmac-sha256; secret "__q7ANbnyliDMuvWgnKOxMLi313JGcTZB5ydMW5CyUGXQ=__"; };key "__example-transfer-key__" { algorithm hmac-sha256; secret "__q7ANbnyliDMuvWgnKOxMLi313JGcTZB5ydMW5CyUGXQ=__"; };Copy to Clipboard Copied! Toggle word wrap Toggle overflow Output appends to the
/etc/named.conffile.You will require this output later on the secondary server as well.
In the
allow-transferstatement, configure the zone in the/etc/named.conffile to require the key for transfers:zone "example.com" { ... allow-transfer { key example-transfer-key; }; };zone "example.com" { ... allow-transfer { key example-transfer-key; }; };Copy to Clipboard Copied! Toggle word wrap Toggle overflow Define that servers must have the key specified in the
example-transfer-keystatement to transfer a zone. However, you can use BIND access control list (ACL) nicknames in theallow-transferstatement.Configure the zone to display the secondary server IP addresses:
zone "example.com" { ... also-notify { 192.0.2.2; 2001:db8:1::2; }; };zone "example.com" { ... also-notify { 192.0.2.2; 2001:db8:1::2; }; };Copy to Clipboard Copied! Toggle word wrap Toggle overflow By default, after updating a zone, BIND notifies all name servers that have a name server (
NS) record in this zone. If you do not plan to add anNSrecord for the secondary server to the zone, you can configure that BIND notifies this server anyway. For that, add thealso-notifystatement with the IP addresses of this secondary server to the zone:Verify the syntax of the
/etc/named.conffile:named-checkconf
# named-checkconfCopy to Clipboard Copied! Toggle word wrap Toggle overflow If the command displays no output, the syntax is correct.
Reload BIND:
systemctl reload named
# systemctl reload namedCopy to Clipboard Copied! Toggle word wrap Toggle overflow If you run BIND in a change-root environment, use the
systemctl reload named-chrootcommand to reload the service.
On the future secondary server:
Add the shared key block to
/etc/named.conf(same as the primary server):key "example-transfer-key" { algorithm hmac-sha256; secret "q7ANbnyliDMuvWgnKOxMLi313JGcTZB5ydMW5CyUGXQ="; };key "example-transfer-key" { algorithm hmac-sha256; secret "q7ANbnyliDMuvWgnKOxMLi313JGcTZB5ydMW5CyUGXQ="; };Copy to Clipboard Copied! Toggle word wrap Toggle overflow Add the secondary zone definition to the
/etc/named.conffile:Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
This server is a secondary server (
type slave) for theexample.comzone. -
The
/var/named/slaves/example.com.zonefile is the zone file. If you set a relative path, as in this example, this path is relative to the directory you set indirectoryin theoptionsstatement. To separate zone files for which this server is secondary from primary ones, you can store them, for example, in the/var/named/slaves/directory. - Any host can query this zone. However, you can specify IP ranges or ACL nicknames to limit the access.
- No host can transfer the zone from this server.
-
The IP addresses of the primary server of this zone are
192.0.2.1and2001:db8:1::2. However, you can specify ACL nicknames. This secondary server will use the key namedexample-transfer-keyto authenticate to the primary server.
-
This server is a secondary server (
Verify the syntax of the
/etc/named.conffile:named-checkconf
# named-checkconfCopy to Clipboard Copied! Toggle word wrap Toggle overflow Reload BIND:
systemctl reload named
# systemctl reload namedCopy to Clipboard Copied! Toggle word wrap Toggle overflow If you run BIND in a change-root environment, use the
systemctl reload named-chrootcommand to reload the service.
-
Optional: Add an
NSrecord for the new secondary server to the zone file on the primary server.
Verification
On the secondary server:
Display the
systemdjournal entries of thenamedservice:journalctl -u named
# journalctl -u namedCopy to Clipboard Copied! Toggle word wrap Toggle overflow Copy to Clipboard Copied! Toggle word wrap Toggle overflow If you run BIND in a change-root environment, use the
journalctl -u named-chrootcommand to display the journal entries.Verify that BIND created the zone file:
ls -l /var/named/slaves/
# ls -l /var/named/slaves/Copy to Clipboard Copied! Toggle word wrap Toggle overflow total 4 -rw-r--r--. 1 named named 2736 Jul 6 15:08 example.com.zone
total 4 -rw-r--r--. 1 named named 2736 Jul 6 15:08 example.com.zoneCopy to Clipboard Copied! Toggle word wrap Toggle overflow Note that, by default, secondary servers store zone files in a binary raw format.
Query a record of the transferred zone from the secondary server:
dig +short @192.0.2.2 AAAA www.example.com
# dig +short @192.0.2.2 AAAA www.example.comCopy to Clipboard Copied! Toggle word wrap Toggle overflow 2001:db8:1::30
2001:db8:1::30Copy to Clipboard Copied! Toggle word wrap Toggle overflow This example assumes that the secondary server you set up in this procedure listens on IP address
192.0.2.2.
2.7. Configuring response policy zones in BIND to override DNS records Copiar enlaceEnlace copiado en el portapapeles!
To rewrite a DNS response to block access to certain domains or hosts by using DNS blocking and filtering, configure response policy zones (RPZ) in BIND. You can configure different actions for blocked entries, such as returning an NXDOMAIN error or not responding to the query.
If you have several DNS servers, configure the RPZ on the primary server, and later configure zone transfers to make the RPZ available on the secondary servers.
Prerequisites
- You have configured BIND as a caching name server.
-
The
namedornamed-chrootservice is running. - You have administrative privileges.
Procedure
Edit the
/etc/named.conffile to add aresponse-policydefinition to theoptionsstatement:Copy to Clipboard Copied! Toggle word wrap Toggle overflow You can set a custom name for the RPZ in the
zonestatement inresponse-policy. However, you must use the same name in the zone definition in the next step.Add a
zonedefinition for the RPZ you set in the last step:Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
This server is the primary server (
type master) for the RPZ namedrpz.local. -
The
/var/named/rpz.localfile is the zone file. In this example, if you set a relative path, this path is relative to the directory you set indirectoryin theoptionsstatement. -
Any hosts defined in
allow-querycan query this RPZ. However, specify IP ranges or BIND access control list (ACL) nicknames to limit the access. - No host can transfer the zone. Allow zone transfers only when you set up secondary servers and only for the IP addresses of the secondary servers.
-
This server is the primary server (
Verify the syntax of the
/etc/named.conffile:named-checkconf
# named-checkconfCopy to Clipboard Copied! Toggle word wrap Toggle overflow If the command displays no output, the syntax is correct.
Create the
/var/named/rpz.localfile with the following content:Copy to Clipboard Copied! Toggle word wrap Toggle overflow This zone file:
-
Sets the default time-to-live (TTL) value for resource records to 10 minutes. Without a time suffix, such as
hfor hour, BIND interprets the value as seconds. - Has the required start of authority (SOA) resource record with details about the zone.
-
Sets
ns1.example.comas an authoritative DNS server for this zone. To be functional, a zone requires at least one name server (NS) record. However, to be compliant with RFC 1912, you require at least two name servers. -
Return an
NXDOMAINerror for queries toexample.organd hosts in this domain. -
Drop queries to
example.netand hosts in this domain.
-
Sets the default time-to-live (TTL) value for resource records to 10 minutes. Without a time suffix, such as
Verify the syntax of the
/var/named/rpz.localfile:named-checkzone rpz.local /var/named/rpz.local
# named-checkzone rpz.local /var/named/rpz.localCopy to Clipboard Copied! Toggle word wrap Toggle overflow zone __rpz.local/IN__: loaded serial __2022070601__ OK
zone __rpz.local/IN__: loaded serial __2022070601__ OKCopy to Clipboard Copied! Toggle word wrap Toggle overflow Reload BIND:
systemctl reload named
# systemctl reload namedCopy to Clipboard Copied! Toggle word wrap Toggle overflow If you run BIND in a change-root environment, use the
systemctl reload named-chrootcommand to reload the service.
Verification
Try to resolve a host in the
example.orgdomain that the RPZ is configured to return anNXDOMAINerror:dig @localhost www.example.org
# dig @localhost www.example.orgCopy to Clipboard Copied! Toggle word wrap Toggle overflow ... ;; ->>HEADER<<- opcode: QUERY, status: **NXDOMAIN**, id: 30286 ...
... ;; ->>HEADER<<- opcode: QUERY, status: **NXDOMAIN**, id: 30286 ...Copy to Clipboard Copied! Toggle word wrap Toggle overflow This example assumes that BIND runs on the same host and responds to queries on the
localhostinterface.Try to resolve a host in the
example.netdomain that the RPZ is configured to drop queries:dig @localhost www.example.net
# dig @localhost www.example.netCopy to Clipboard Copied! Toggle word wrap Toggle overflow ... ;; connection timed out; no servers could be reached ...
... ;; connection timed out; no servers could be reached ...Copy to Clipboard Copied! Toggle word wrap Toggle overflow