Networking

Azure Firewall: diagnose DNS cache divergence before opening rules

A production runbook for separating DNS cache, upstream resolver, FQDN rules and the Azure Firewall network path before broadening policy or changing a zone.

29 Oct 2026 azureazure-firewalldnsdns-proxyfqdnnetworkingobservabilitykqlrunbookrollbackproduction

An internal API moves from 10.42.8.20 to 10.42.8.21. The DNS record has changed, but some workloads still call the old address. Others receive NXDOMAIN, and Azure Firewall denies part of the traffic even though the FQDN rule exists. An administrator’s workstation already sees the new record.

The risky response is to add both IP addresses to a rule, allow the whole subnet temporarily, or edit the private zone again. Those actions blur four separate facts: DNS content, cache state, the resolver actually used, and the firewall decision. This runbook qualifies each layer and ends with a bounded choice: wait for a known TTL, repair the forwarder or client, restore the previous record, keep the cutover, or roll it back.

Freeze one reproducible observation

Start with an exact tuple: workload, FQDN, queried resolver, returned address, port, UTC timestamp, and connection result. Preserve the old and new records, their TTLs, the change time, the Azure Firewall policy, and the last healthy test.

text 01-dns-incident-scope.txt
Incident
Workload: orders-worker-07
Source subnet: spoke-prod/workers
FQDN: inventory.internal.example
Expected address: 10.42.8.21
Previous address: 10.42.8.20
Protocol: TCP 8443
Change time: 2026-10-29T14:05:00Z
First failure: 2026-10-29T14:08:17Z

Evidence to preserve
Resolver configured on the workload
A, CNAME and SOA answers with TTL
Azure Firewall DNS and policy configuration
Firewall decision for source, destination and port
Health of old and new backends

A laptop test does not qualify the workload path. Run read-only checks from the same network identity: the affected VM, an approved diagnostic pod, a private worker, or the service console. When instances disagree, retain at least one healthy instance and one failing instance as canaries.

Map the effective DNS chain

With DNS proxy enabled, Azure Firewall accepts client queries on its private IP and forwards them to its configured DNS servers. It does not automatically merge private zones visible in its VNet with answers from the upstream resolver. If that resolver cannot reach the zone, the proxy forwards an incomplete or negative answer.

text 02-resolution-chain.txt
Workload
-> DNS server received through VNet, DHCP or runtime configuration
-> Azure Firewall private IP when DNS proxy is the approved path
-> DNS servers configured on Firewall Policy
-> Private Resolver, AD DNS or another approved upstream
-> authoritative public or private zone

Traffic after resolution
-> effective route from source subnet
-> Azure Firewall rule processing
-> old or new backend
-> symmetric return path

Inspect deployed state, not only the architecture diagram. A parent policy can supply DNS settings while a child policy overrides them. A workload may also retain its former DNS servers until its lease or runtime is renewed.

bash 03-capture-firewall-dns.sh
RG="rg-network-prod"
FIREWALL="azfw-prod"
POLICY="azfw-policy-prod"
VNET="vnet-spoke-prod"

az network firewall show --resource-group "$RG" --name "$FIREWALL" --query '{privateIps:ipConfigurations[].privateIPAddress,policy:firewallPolicy.id}' --output json

az network firewall policy show --resource-group "$RG" --name "$POLICY" --query '{dns:dnsSettings,parent:basePolicy.id}' --output json

az network vnet show --resource-group "$RG" --name "$VNET" --query '{dnsServers:dhcpOptions.dnsServers,subnets:subnets[].name}' --output json

The expected result is a chain with no implicit hop: the client queries the firewall private IP, DNS proxy is enabled, and the upstream servers can resolve the affected namespace.

Compare answers at every layer

Query the resolver configured on the workload, then each approved upstream resolver. Request A, CNAME, and SOA records and retain the displayed TTL. Repeat the query over a short window to distinguish a stable answer from an address pool or a change still moving through caches.

bash 04-compare-dns-answers.sh
FQDN="inventory.internal.example"
FIREWALL_DNS="10.10.0.4"
UPSTREAM_DNS="10.10.2.4"

cat /etc/resolv.conf
resolvectl status 2>/dev/null || true

for SERVER in "$FIREWALL_DNS" "$UPSTREAM_DNS"; do
echo "resolver=$SERVER"
dig +noall +answer "$FQDN" A @"$SERVER"
dig +noall +answer "$FQDN" CNAME @"$SERVER"
done

dig +noall +answer internal.example SOA @"$UPSTREAM_DNS"

DNS proxy retains a positive answer according to its TTL, capped at one hour. A negative answer can remain cached according to its TTL, capped at thirty minutes. Correcting a record immediately after an NXDOMAIN therefore does not guarantee immediate recovery. Record the first faulty answer and calculate the expected cache expiry instead of stacking speculative changes.

Keep four states distinct:

  • proxy and upstream both return the old IP: upstream content or its cache is still old;
  • upstream returns the new IP while the proxy retains the old one: the proxy cache TTL is still active;
  • proxy returns the new IP while the workload retains the old one: a local cache, runtime, or connection pool holds state;
  • answers alternate: multiple resolvers, multiple records, or inconsistent forwarders participate in the path.

Tie DNS evidence to the rule type

An FQDN network rule and an application rule do not make the same decision. For a network rule, Azure Firewall resolves the FQDN into addresses and refreshes the mapping regularly; old addresses do not disappear instantly. For HTTP/S, prefer an application rule when the protocol permits it. It can qualify the name at the application layer, including through SNI, instead of reducing the decision to a shared IP.

This distinction prevents a false diagnosis. When an FQDN network rule allows inventory.internal.example, an address change can create a window where the client and firewall do not share the same mapping. Adding a permanent IP rule bypasses the FQDN contract and leaves an orphaned permission after the incident.

Identify the collection that actually decided the flow. A higher-priority network rule can mask the expected application rule. Preserve the group, collection, rule, action, source, destination, and port.

kusto 05-correlate-firewall-dns-window.kql
let start = datetime(2026-10-29T14:00:00Z);
let stop = datetime(2026-10-29T14:40:00Z);
let sourceIp = "10.20.4.17";
let oldIp = "10.42.8.20";
let newIp = "10.42.8.21";
AzureDiagnostics
| where TimeGenerated between (start .. stop)
| where Category in (
  "AzureFirewallNetworkRule",
  "AzureFirewallApplicationRule",
  "AzureFirewallDnsProxy")
| where msg_s has_any (sourceIp, oldIp, newIp, "inventory.internal.example")
| project TimeGenerated, Category, msg_s
| order by TimeGenerated asc

Adapt categories to the firewall diagnostic mode. Missing DNS rows can mean that the category is not collected; they do not prove that the client bypassed the proxy. Confirm the resolver path through workload configuration and a directed DNS query.

Repair the smallest faulty layer

The evidence determines the correction:

  • wrong upstream record or forwarder: repair the zone or forwarding rule, then verify the answer directly on the upstream resolver;
  • valid positive cache entry: keep the old backend available until observed expiry, or restore the previous record when the cutover cannot wait;
  • negative cache entry: repair the authoritative cause first, read the SOA TTL, and wait or flush only a cache that the operating procedure allows you to flush;
  • client outside the approved DNS path: correct VNet or runtime configuration and renew one canary client;
  • wrong rule type: use an application rule for HTTP/S when compatible, or precisely scope the FQDN network rule for other protocols;
  • route or backend failure: leave policy intact and repair the network path or target service.

Do not disable and re-enable DNS proxy in production merely to attempt a cache flush without a validated procedure. That action changes the resolver for every affected client and can turn one namespace divergence into a broad DNS outage.

Validate the cutover and prepare rollback

Validate from at least two instances: one that failed and one that remained healthy. Both must receive the intended address from the approved resolver, establish a new connection to the correct backend, and produce an explainable firewall decision. Confirm that an unauthorized FQDN remains denied as well. A positive test alone does not prove that policy stayed narrow.

text 06-dns-cutover-gates.txt
Promote
Approved resolver returns the new answer with an understood TTL
Failing and healthy canaries reach the new backend
Firewall logs show the expected rule and destination
Old backend receives no new sessions after the drain window
A negative canary remains denied

Rollback
Resolver answers still diverge after the measured cache window
New backend is unhealthy from the production path
Firewall decision cannot be tied to the approved rule
Old backend cannot remain available for the drain period

Rollback action
Restore the last known-good record and TTL
Keep the previous backend serving
Remove only the temporary bounded change
Preserve DNS answers and firewall logs for comparison

Prepare rollback before the DNS edit: previous record, previous TTL, health of the former backend, and retention duration. Lowering TTL during the incident does not erase answers already cached with the former TTL.

Conclusion

DNS divergence around Azure Firewall is not mysterious propagation. It can be decomposed into an authoritative answer, one or more caches, the resolver actually used, the firewall’s FQDN mapping, and a connection to one exact address.

The production decision then becomes testable: wait for a measured TTL, repair the resolver or client, keep the cutover, or restore the last healthy record and backend pair. None of those findings justifies a broad IP allow rule as an implicit rollback.