NSSYNC |
|
DNS Zone Files Maintenance Utility |
Sergey Poznyakoff |
4.3 Synchronization Block
A synchronization block defines a set of zones to be
synchronized from the database and configures SQL statements which
return the zone data. This set is identified by synchronization
tag, supplied as the argument to the sync
statement:
# Define a synchronization block. sync tag { # zone configuration file zone-conf pat; # pattern for new zone file names zonefile-pattern pat; # add these statements to each generated zone file add-statements text; # a query for retrieving SOA records soa-query string; # a query for retrieving NS and similar records ns-query string; # a query for retrieving the rest of RRs rr-query string; # a query for retrieving RRs from reverse delegation zones rev-rr-query string; }
Statements within the sync
block configure the zones:
- Configuration: zone-conf pat
Defines the pattern for the name of zone configuration file for zones in this synchronization block. If not supplied, the global
zone-conf
statement will be used instead (see zone-conf).
- Configuration: zonefile-pattern pat
Defines the pattern for zone file names. If not supplied, the global
zonefile-pattern
statement will be used instead (see zonefile-pattern).
- Configuration: add-statements text
Append text to each generated zone statement. For example, the following can be used to redefine forwarders and query ACLs for zones in this synchronization block:
add-statements <<EOT forwarders { /* empty */ }; allow-query { local-query-only; }; EOT;
Notice the use of the here-document construct.
The following statements define which zones pertain to this particular synchronization block:
- Configuration: ns-query string
A query for retrieving NS and similar records. Use the ‘$zone’ reference for the zone name.
- Configuration: rr-query string
A query for retrieving the rest of RRs. Use the ‘$zone’ reference for the zone name.
- Configuration: rev-rr-query string
A query for retrieving RRs from reverse delegation zones. Use the ‘$zone’ reference for the zone name.
Here is an example of a working sync
directive:
sync external { zone-conf "/var/namedb/nssync/zones.external"; zonefile-pattern "/var/namedb/external/db.${zone}"; soa-query "select zone, ttl, type, data, resp_person, " "serial, refresh, retry, expire, minimum " "from dns_soa where type='SOA' " "and view='external' order by zone"; ns-query "select ttl, type, data " "from dns_soa where zone='$zone' " "and type<>'SOA' and view='external'"; rr-query "select host, ttl, type, mx_priority, " "case when type='TXT' then " "concat('\"', data, '\"') " "else data end " "from dns_records " "where zone='$zone' and view='external' " "order by 1"; rev-rr-query "select host, ttl, type, mx_priority, " "case when type='TXT' then " "concat('\"', data, '\"') " "else data end " "from dns_records " "where zone='$zone' and view='external' " "order by cast(host as unsigned)"; }
This document was generated on April 24, 2015 using makeinfo.
Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved.