Active Directory DNS Configuration: Forwarders, Scavenging and Zones

The settings that break most often in Active Directory DNS: replication scope, DC client DNS, forwarders, aging/scavenging and DHCP updates; with audit commands.
Technical summary
Technology
AD-integrated DNS, DnsServer PowerShell module, DHCP, dcdiag
Topic
Correct configuration and operation of AD-integrated internal DNS
Level
Intermediate
Prerequisites
  • Basic DNS concepts (zones, record types, recursive queries)
  • Domain Admins or DnsAdmins rights
In this article8 sections

DNS is the root of a large share of “I can’t join the domain,” “the GPO doesn’t come through” and “sign-in is slow” complaints. Clients find DCs through SRV records; Kerberos and Group Policy depend on correct name resolution. If DNS is wrong, Active Directory works wrong too. Below we explain the replication scopes of AD-integrated DNS, DCs’ DNS client settings, forwarder options, how aging/scavenging works, and dynamic updates with DHCP, from the point of view of operating internal DNS, along with the points where things break in the field.

AD-integrated zones and replication scope

An AD-integrated zone keeps its records in the directory database rather than a file and is replicated with AD replication. This makes multi-master updates possible, as well as secure dynamic updates where only authenticated computers can write records. The replication scope determines which DCs the zone is copied to:

Scope Where it is copied Typical use
Forest (ForestDnsZones) All DNS server DCs in the forest The _msdcs zone, zones that must resolve from anywhere in the forest
Domain (DomainDnsZones) All DNS server DCs in the domain The domain’s primary zone (default)
Domain partition All DCs in the domain (even without the DNS role) Legacy Windows 2000 compatibility; not needed in new deployments
Custom application partition DCs enlisted in the partition Distributing the zone only to specific DCs

In single-domain forests, Forest and Domain scope in practice cover the same servers; the difference appears in multi-domain forests. Check that dynamic updates on the primary zone are in secure mode only. A zone with “Nonsecure and secure” selected is a zone where every device on the network can write records:

Get-DnsServerZone | Where-Object IsDsIntegrated |
  Select-Object ZoneName, ReplicationScope, DynamicUpdate, IsReverseLookupZone

Set-DnsServerPrimaryZone -Name "contoso.local" -DynamicUpdate Secure

Create reverse lookup zones as AD-integrated with secure updates too. If a reverse zone is missing, some applications and log analysis tools can’t find names from IPs; hours are lost during incident review.

DCs’ DNS client settings

The misconfiguration we come across most often in server and system infrastructure is the DNS client setting on the DC’s network card. The practical rule:

  • Primary DNS: Another DC in the same site.
  • Secondary DNS: The DC itself, as the loopback address 127.0.0.1. Loopback should be in the list, but not first.
  • No external DNS address: Modem, provider or public resolver addresses aren’t entered in the DNS client settings of DCs and domain members. An 8.8.8.8 added “as a backup” is the classic source of intermittent, hard-to-diagnose failures.

A DC pointing to itself first can cause resolution delays at startup while the DNS service waits for AD to be ready, and lead to an “island” situation: the DC feeds only from its own copy and can’t stay current. On DCs with more than one network card (e.g. a backup network), only the card serving clients should register in DNS; turn off “Register this connection’s addresses in DNS” on the other cards. If you don’t, clients are directed to an IP they can’t reach. The symptom looks random. The cause isn’t.

Forwarders, conditional forwarders and root hints

To resolve a name not in its own zones, an internal DNS server either does recursive resolution with root hints or passes the query to a forwarder. Firewall policy decides: if DCs aren’t supposed to go out to the internet directly on UDP/TCP 53, queries go to a forwarder on the firewall or in a separate resolver layer.

Set-DnsServerForwarder -IPAddress 10.10.0.1, 10.10.0.2 -UseRootHint $false
Get-DnsServerForwarder

Add-DnsServerConditionalForwarderZone -Name "partner.local" `
  -MasterServers 172.16.5.10, 172.16.5.11 -ReplicationScope "Forest"
  • A forwarder is a server-level setting and isn’t replicated with AD. It is set separately on each DC; it’s one of the first things to check when a new DC is added.
  • A conditional forwarder sends a specific domain name to specific servers: a partner forest, a branch behind a VPN, a private cloud DNS zone. If it is stored in AD with -ReplicationScope, it is distributed to all DCs.
  • -UseRootHint $false prevents falling back to root hints when the forwarders don’t respond. Behavior is consistent in networks with strict egress policy; but when the forwarders go down, external resolution stops completely. Define at least two forwarders. A single forwarder is a single point of failure.

Separating internal and external domain names, split-horizon and the external-facing resolver architecture belong to the network side; for the design of this layer, see the enterprise DNS architecture and split-horizon article.

Aging and scavenging

When a dynamically registered client leaves the network, its record isn’t deleted on its own. Over time you get several names pointing to the same IP, RDP connections going to the wrong machine and an inventory that doesn’t add up. Aging/scavenging cleans up these old records based on their timestamp. It relies on two intervals:

  • No-refresh interval (7 days by default): After a record gets a new timestamp, the stamp isn’t refreshed during this period; the aim is to avoid unnecessary replication traffic.
  • Refresh interval (7 days by default): The record’s owner can refresh the record during this period. When the sum of the two intervals has passed, the record becomes eligible for cleanup.

The sum of the two intervals shouldn’t be shorter than the DHCP lease time; otherwise records of clients still in use get deleted. Example calculation: in a scope using an 8-day lease, 7+7 days is safe, 2+2 days isn’t. In practice, follow this order:

# Aging at zone level
Set-DnsServerZoneAging -Name "contoso.local" -Aging $true `
  -NoRefreshInterval 7.00:00:00 -RefreshInterval 7.00:00:00

# Automatic scavenging on only one DNS server
Set-DnsServerScavenging -ComputerName DC01 -ScavengingState $true -ScavengingInterval 7.00:00:00

# Preview records that are candidates for deletion
Get-DnsServerResourceRecord -ZoneName "contoso.local" -RRType A |
  Where-Object { $_.Timestamp -and $_.Timestamp -lt (Get-Date).AddDays(-14) } |
  Select-Object HostName, Timestamp, @{n='IP';e={$_.RecordData.IPv4Address}}

Enable scavenging on a single server; that makes it easier to track which server deletes records. It is also possible to restrict which servers are allowed to scavenge in the zone properties (Set-DnsServerZoneAging -ScavengeServers).

Dynamic DNS updates with DHCP

Windows clients update their A records themselves; by default the DHCP server writes the PTR record and, if desired, the records of devices that can’t register themselves. Look at two settings here: with what identity does DHCP do the update, and is the record deleted when the lease expires?

Set-DhcpServerDnsCredential -ComputerName DHCP01 -Credential (Get-Credential CONTOSO\svc-dhcpdns)

Set-DhcpServerv4DnsSetting -ComputerName DHCP01 -DynamicUpdates Always `
  -DeleteDnsRROnLeaseExpiry $true -UpdateDnsRRForOlderClients $true

If no dedicated credential is defined, the DHCP service writes records with the server’s computer account. If DHCP runs on a DC, records are created with the DC account’s rights; a dedicated, unprivileged service account removes this risk. Define the same credential on two DHCP servers running in failover; otherwise one can’t update a record created by the other and the client name stays on the old IP. For DHCP redundancy itself, see the Windows Server DHCP failover configuration article.

Symptoms of misconfiguration

Symptom Likely cause First check
Domain join error The client uses external DNS ipconfig /all, nltest /dsgetdc
GPO not applying, error 1058 SRV or DC A record doesn’t resolve SRV query with Resolve-DnsName
RDP goes to the wrong machine Old A records, scavenging off Get-DnsServerZoneAging
Intermittent access to external sites A single or unresponsive forwarder Get-DnsServerForwarder
Different resolution on the new DC Forwarder not moved to the new DC Comparison across servers
Clients get an unreachable IP The DC’s extra card is registered in DNS DC A records in the zone

If the symptom is on the GPO side, use the Group Policy troubleshooting article for detailed diagnosis.

Auditing with PowerShell

The commands below are the core of the DNS audit to be done during scheduled maintenance with the DnsServer PowerShell module and built-in tools. Run them on each DC and put the output side by side; the line that differs is where the problem is:

# DC discoverability
Resolve-DnsName -Type SRV _ldap._tcp.dc._msdcs.contoso.local
nltest /dsgetdc:contoso.local

# Server configuration
Get-DnsServerForwarder
Get-DnsServerScavenging
Get-DnsServerZoneAging -Name "contoso.local"
Get-DnsServerRootHint

# Comprehensive DNS test
dcdiag /test:dns /v /e /f:C:\Temp\dcdiag-dns.txt

# Re-register missing SRV records (on the DC)
nltest /dsregdns
ipconfig /registerdns

In the dcdiag /test:dns output, the forwarder, delegation, dynamic update and record registration headings should be “Pass” for each DC. Adding this audit to the Active Directory health check process catches problems before they turn into user complaints. We take on regular operation of DNS and directory services within server and cloud management.

Frequently asked questions

Is it a problem to add an address like 8.8.8.8 to a domain controller’s DNS settings?

Yes. When a DC or client sends a query to an external resolver, it can’t find the SRV records in the internal zone; the result is domain join, Group Policy and authentication errors. External resolution is done on the DNS server side with forwarders.

After enabling scavenging, when do records start being deleted?

After aging is enabled on the zone, at least one refresh interval (7 days by default) must pass; no cleanup happens before that. Then dynamic records whose timestamp is older than the sum of the no-refresh and refresh intervals (7+7 = 14 days by default) are deleted in the first scavenging run. Review the candidate list in the week you enable aging.

Should I define a conditional forwarder separately on every DNS server?

No need. If a conditional forwarder is created to be stored in Active Directory, it is automatically distributed to all DNS servers in the replication scope you choose. A normal forwarder, however, is a server-level setting and is configured separately on each server.

Are static records deleted by scavenging?

Manually created records have a timestamp of zero, and scavenging doesn’t delete them. Dynamically created records carry a timestamp and can be deleted; make critical server records static.

Support

Contact us for support or a discovery session on this topic.

Contact form
[email protected]

Eretek System Support

Server installation, configuration, incident response and scheduled maintenance. Active Directory, virtualization and backup are managed with the same discipline.

Knowledge Center

Other articles