SkillPilotAI

dnscmd (2/2)

Part 2 of dnscmd: where AD-integrated zones are stored (application directory partitions) and how to tune the DNS server with dnscmd /config, both server-wide and per zone. A BIND 9 lab shows the matching Linux settings because dnscmd runs only on Windows (where dnscmd found nothing on the office PC, so Windows outputs are from Microsoft Learn).

204.1 Why is it used?

  • Control which DCs replicate a DNS zone (domain-wide, forest-wide or a chosen set).
  • Turn recursion, forwarding, cache size, DNSSEC and logging on or off for the whole server.
  • Lock down zone transfers and dynamic updates per zone.
  • Settings are saved in the server's registry over an RPC call from the admin PC.

204.2 DNS application directory partitions

Where AD-integrated zone data replicates
  1. 1.Zone records live in Active Directory, not in files

  2. 2.DomainDnsZones: replicated to all DNS servers (DCs) of the same domain (DC1 -> DC2)

  3. 3.ForestDnsZones: replicated across the whole forest, even to DC3 in emea.contoso.com

  4. 4.Custom partition (dns.contoso.com): only enlisted DCs keep a replica

  5. 5.DC2 enlisted -> gets the zone; DC3 not enlisted -> does not

Output
dnscmd [<servername>] /enumdirectorypartitions [/custom]dnscmd [<servername>] /directorypartitioninfo <partitionFQDN> [/detail]dnscmd [<servername>] /createdirectorypartition <partitionFQDN>dnscmd [<servername>] /enlistdirectorypartition <partitionFQDN>dnscmd [<servername>] /createbuiltindirectorypartitions [/forest] [/alldomains]dnscmd [<servername>] /zonechangedirectorypartition <zonename> {[<newpartitionname>] | [<zonetype>]}
PartitionReplicates toSwitch
DomainDnsZonesAll DNS servers of the domain/domain
ForestDnsZonesAll DNS servers in the forest/forest
CustomOnly enlisted servers/createdirectorypartition + /enlistdirectorypartition
Legacy (domain partition)All DCs of the domain, incl. pre-AD-partition DCs/legacy
  • /deletedirectorypartition and /unenlistdirectorypartition remove a partition or a replica.
  • /zonechangedirectorypartition moves a zone to another partition.

204.3 How /config works (server level)

Recursion on vs /norecursion 1
  1. 1.Admin PC sends dnscmd /config over RPC; dnssvr1 updates its registry

  2. 2.Client (192.168.1.20) asks for a partner.com name not in dnssvr1's zones

  3. 3.Recursion on: dnssvr1 forwards to 192.168.1.53 and returns the answer

  4. 4.Admin sets /norecursion 1

  5. 5.Same query now gets REFUSED (own zones still answered)

Linux equivalent: every named.conf line notes the matching dnscmd parameter; the server forwards only to the lab partner DNS.

Output
options {  recursion yes;           // /norecursion 0  allow-recursion { 192.168.224.0/24; };  forwarders { 192.168.224.20; };  forward only;            // /isslave 1  querylog no;             // /loglevel 0x0  max-cache-size 32m;      // /maxcachesize  max-cache-ttl 86400;     // /maxcachettl  max-ncache-ttl 900;      // negative TTL  dnssec-validation auto;  // DNSSEC check};zone "test.contoso.com" {  allow-transfer { 192.168.224.30; };  allow-update { 192.168.224.30; };};
Output
$ named -vBIND 9.18.49 (Extended Support Version) <id:cd4a53b>$ rndc statusnumber of zones: 2 (0 automatic)query logging is OFFserver is up and running

204.4 Recursion and forwarding

Output
/norecursion 0|1         recursion on | off/isslave 0|1             0 resolve itself | 1 fail if forwarders fail/forwardingtimeout 5     forwarder wait (s)/forwarddelegations 0|1  subzone | forwarders/recursionretry 3        seconds before retry/recursiontimeout 15     stop trying remote (s)/sendport 0              source port, 0 = random/serverlevelplugindll <dll>   plugin on (empty = off)
Output
dnscmd reskit.com /info isslavednscmd reskit.com /info recursiontimeout
Output
C:\> dnscmd reskit.com /info isslaveQuery result:Dword: 0 (00000000)Command completed successfully.C:\> dnscmd reskit.com /info recursiontimeoutDword: 15 (0000000F)
Terminal
# named.conf: recursion no;rndc reconfigdig @192.168.224.10 app.partner.lab Adig @192.168.224.10 web01.test.contoso.com A
Output
$ rndc reconfig$ named-checkconf -p | grep recursion    recursion no;$ dig @192.168.224.10 app.partner.lab A;; ->>HEADER<<- opcode: QUERY, status: REFUSED, id: 7284;; WARNING: recursion requested but not available$ dig @192.168.224.10 web01.test.contoso.com A;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 15307web01.test.contoso.com.  3600  IN  A  192.168.224.50

204.5 Cache, EDNS and DNSSEC

Output
/maxcachesize 10240       cache max (KB)/maxcachettl 86400        max TTL (0 = no cache)/maxnegativecachettl 900  negative answer TTL/ednscachetimeout 604800  EDNS info cache (s)/enableednsprobes 0|1     EDNS probes off|on/enablednssec 0|1         DNSSEC off|on
Terminal
rndc validation statusdig @192.168.224.10 app.partner.lab Agrep -iE 'trust|DNSKEY' named.logrndc validation offdig @192.168.224.10 app.partner.lab A
Output
$ rndc validation statusDNSSEC validation is enabled (view _default)$ dig @192.168.224.10 app.partner.lab A;; ->>HEADER<<- opcode: QUERY, status: SERVFAIL, id: 50945$ grep -iE 'trust|DNSKEY' named.log13:05:11.248 REFUSED unexpected RCODE resolving './DNSKEY/IN': 192.168.224.20#5313:05:11.248 managed-keys-zone: Unable to fetch DNSKEY set '.': failure13:05:18.940 broken trust chain resolving 'app.partner.lab/A/IN': 192.168.224.20#53$ rndc validation offDNSSEC validation is disabled (view _default);; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 55519app.partner.lab.  3600  IN  A  192.168.224.60
  • SERVFAIL here: the isolated lab cannot fetch the root DNSKEY, so the trust chain is broken.
  • Turning validation off was only for the lab; on a real server keep DNSSEC validation on.
Terminal
named-checkconf -p | grep max-cacherndc dumpdb -cachegrep -E 'Cache dump|partner' named_dump.db
Output
$ named-checkconf -p | grep max-cache    max-cache-size 33554432;    max-cache-ttl 86400;$ grep -E 'Cache dump|partner' named_dump.db; Cache dump of view '_default' (cache _default)app.partner.lab.  3587  IN A  192.168.224.60

204.6 Logging: Event Viewer, Dns.log, /loglevel

Output
/eventloglevel 0|1|2|4         none | errors | +warnings | +info (default 4)/logfilemaxsize 0x400000       Dns.log max 4 MB/logfilepath C:\DNSLogs\dns.log/logipfilterlist 10.0.0.5,10.0.0.6   only these IPs/loglevel 0x6210               queries+answers+receive+UDP/loglevel 0x0                  debug log off (default)
/loglevel flagLogs
0x0No debug log (default)
0x10 / 0x20Queries + notifications / updates
0x100 / 0x200Question transactions / answers
0x1000 / 0x2000Sent / received packets
0x4000 / 0x8000UDP / TCP packets
0xFFFFAll packets
0x1000000Full packets

Add hex values to combine flags (0x6210). Debug logging is heavy: set /loglevel back to 0 after troubleshooting. BIND equivalent: rndc querylog.

Terminal
rndc status | grep 'query logging'rndc querylog ondig @192.168.224.10 web01.test.contoso.com A +shortdig @192.168.224.10 app.partner.lab A +shortcat /var/log/named/query.logrndc querylog off
Output
$ rndc status | grep 'query logging'query logging is OFF$ rndc querylog onquery logging is ON$ dig @192.168.224.10 web01.test.contoso.com A +short192.168.224.50$ dig @192.168.224.10 app.partner.lab A +short192.168.224.60$ cat /var/log/named/query.log13:05:30.636 client @0x7b7e7db2f230 192.168.224.20#44060 (web01.test.contoso.com): query: web01.test.contoso.com IN A +E(0)K (192.168.224.10)13:05:30.692 client @0x7b7e7db2f230 192.168.224.20#45139 (app.partner.lab): query: app.partner.lab IN A +E(0)K (192.168.224.10)

204.7 Security, update options, aging and other server settings

Output
/enableglobalqueryblocklist 0|1     off | on (default)/globalqueryblocklist isatap wpad   replace the list/secureresponses 0|1                cache all | same subtree only/rpcprotocol 0x1 | 0x2 | 0x4        TCP/IP | named pipes | LPC/updateoptions 0x30F                common standard + secure mix/updateoptions 0x80000000           dynamic update disabled/scavenginginterval 168             clean stale records every 7 days/dstombstoneinterval 1209600        keep deleted AD records 14 days/roundrobin 0|1                     rotate A records (default 1)/bootmethod 0|1|2|3                 clear | BIND file | registry | AD
  • The global query block list blocks isatap and wpad by default, because attackers can use them for a fake proxy.
  • /secureresponses 1 protects against cache pollution.
  • /updateoptions picks which record types (SOA, NS, delegation, server host) dynamic update may not change.
  • /strictfileparsing 1 stops loading a zone at a bad record; /notcp is obsolete.

204.8 Zone-level settings

Zone transfer and dynamic update rules
  1. 1.Secondary (192.168.1.30) sends AXFR; it is in securesecondaries -> gets the zone copy

  2. 2.Unknown PC (192.168.1.99) sends AXFR -> Transfer failed

  3. 3.Client sends a dynamic update

  4. 4./allowupdate 1 -> update accepted and the record is registered

Zone optionMeaning
/aging 1|0Scavenging on/off for this zone
/refreshinterval, /norefreshintervalAging intervals in hours (168 = 7 days)
/allowupdate <value>Dynamic updates allowed or not
/securesecondariesWho may take an AXFR
/forwarderslave, /forwardertimeoutOverride server settings for a conditional forwarder zone
/allownsrecordsautocreation <IPs>Override auto-creation of NS records
Output
dnscmd /config test.contoso.com /aging 1dnscmd /config partner.com /forwardertimeout 5dnscmd reskit.com /zoneinfo test.reskit.com refreshintervaldnscmd reskit.com /zoneinfo test.reskit.com aging
Output
C:\> dnscmd reskit.com /zoneinfo test.reskit.com refreshintervalZone query result:Dword: 168 (000000A8)Command completed successfully.C:\> dnscmd reskit.com /zoneinfo test.reskit.com agingDword: 0 (00000000)

BIND lab: allow-transfer = /securesecondaries, allow-update = /allowupdate.

Terminal
dig -b 192.168.224.20 test.contoso.com AXFRdig -b 192.168.224.30 test.contoso.com AXFRgrep -E 'transfer|AXFR' named.log
Output
$ dig -b 192.168.224.20 test.contoso.com AXFR; Transfer failed.$ dig -b 192.168.224.30 test.contoso.com AXFRtest.contoso.com.  3600  IN  SOA  dnssvr1.test.contoso.com. admin.test.contoso.com. 2026110901 3600 600 86400 900test.contoso.com.  3600  IN  NS  dnssvr1.test.contoso.com.dnssvr1.test.contoso.com. 3600  IN  A  192.168.224.10intranet.test.contoso.com. 3600  IN  CNAME  web01.test.contoso.com.web01.test.contoso.com.  3600  IN  A  192.168.224.50$ grep -E 'transfer|AXFR' named.log13:05:52.407 client @0x7b7e7db653b0 192.168.224.20#40767 (test.contoso.com): zone transfer 'test.contoso.com/AXFR/IN' denied13:05:54.484 client @0x7b7e7db653e0 192.168.224.30#34117 (test.contoso.com): transfer of 'test.contoso.com/IN': AXFR started (serial 2026110901)
Output
server 192.168.224.10local 192.168.224.20zone test.contoso.comupdate add app01.test.contoso.com 300 A 192.168.224.70send# second try: local 192.168.224.30
Output
$ nsupdate   (local 192.168.224.20)update failed: REFUSED$ nsupdate   (local 192.168.224.30)update sent$ dig @192.168.224.10 app01.test.contoso.com A +noall +answerapp01.test.contoso.com.  300  IN  A  192.168.224.70$ grep -E 'update|updating' named.log13:05:42.320 zone 'test.contoso.com' allows unsigned updates from remote hosts, which is insecure13:05:59.047 client @0x7b7e7db42290 192.168.224.20#33939: update 'test.contoso.com/IN' denied

204.9 Comparison: server level vs zone level

PointServer levelZone level
Syntaxdnscmd /config /<parameter> <value>dnscmd /config <zonename> /<parameter> <value>
ScopeWhole DNS serverOnly that zone
Examplesnorecursion, forwarders, cache, loglevel, DNSSECaging, allowupdate, securesecondaries
Read with/info <setting>/zoneinfo <zone> <setting>

204.10 Common mistakes

  • Thinking /norecursion 1 turns DNS off: own zones still get NOERROR, only outside names get REFUSED.
  • Leaving /loglevel debug flags on: Dns.log grows fast and costs performance.
  • Allowing unsigned dynamic updates by IP (BIND warns it is insecure); use TSIG or Windows secure update.
  • Letting any PC pull the zone instead of restricting /securesecondaries.

204.11 Interview tips

  • Server level = whole server (recursion, forwarders, cache), saved in the registry; zone level needs the zone name (aging, allowupdate, securesecondaries).
  • Authoritative-only servers: recursion off is the best practice.
  • Outside PC can download your zone: restrict /securesecondaries (BIND allow-transfer).
  • DomainDnsZones vs ForestDnsZones: domain-wide vs forest-wide replication.