Sysmon · Network
Sysmon 22 · DNSEvent (DNS query)
Sysmon Event ID 22 records DNS queries made through the Windows DNS client along with the process that made them and the results. It links a domain lookup to a specific executable, which DNS server logs cannot do, making it valuable for C2 discovery, DNS tunnelling and phishing payload tracking.
Where it is logged
Microsoft-Windows-Sysmon/Operational on endpoints and servers. Requires Sysmon 10 or later on Windows 8.1 / Server 2012 R2 or later (it relies on the DNS client ETW provider) and a config that includes DnsQuery, usually with exclusions for common domains. Lookups that bypass the Windows DNS client (e.g. tools using their own resolver or DNS over HTTPS) are not captured.Key fields to read
| Field | What it tells you |
|---|---|
| QueryName | Domain name queried. |
| QueryStatus | Result code; 0 success, 9003 name does not exist (NXDOMAIN). |
| QueryResults | Returned records, e.g. ::ffff:203.0.113.45; or type: 5 alias.example; for CNAMEs. |
| Image | Process that performed the lookup. |
| User | Account context of the process (newer Sysmon versions). |
| ProcessGuid | Pivot to Sysmon 1 and Sysmon 3 for the same process. |
Sample event
Log Name: Microsoft-Windows-Sysmon/Operational
EventID: 22
UtcTime: 2026-11-19 10:41:17.884
Computer: NW-FIN-WS07.northwind.local
ProcessGuid: {4f1c2b7e-a3f1-6740-6c05-000000002200}
ProcessId: 9012
QueryName: q7f3k9x2mzl0v8b4n1c6d5a2h7j0p3r9.t.cdn-update-check.example
QueryStatus: 0
QueryResults: ::ffff:198.51.100.23;
Image: C:\ProgramData\Intel\svch.exe
User: NORTHWIND\l.brandtHow to triage it
- 1Check
Image: browsers and system services resolving many domains is normal; scripting engines, Office or binaries inProgramData/Tempresolving external domains are not. - 2Assess
QueryName: domain age and reputation, look-alike spelling, and whether it is new to the environment. - 3Look for tunnelling patterns: long, high-entropy subdomain labels, many unique subdomains under one parent domain, or TXT-heavy traffic.
- 4Check
QueryStatusvolume: many9003NXDOMAIN results from one process can indicate a DGA. - 5Pivot on
ProcessGuidandQueryResultsIPs to Sysmon 3 connections and to proxy/firewall logs to confirm communication.
Benign vs suspicious
Usually benign
- Browsers, Teams and Microsoft 365 resolving hundreds of CDN and telemetry domains.
- Security agents and update services resolving cloud endpoints.
- CDN or anti-spam services that legitimately use long hashed subdomains.
Red flags
- High-entropy subdomains (30+ random characters) under the same parent domain repeated many times: DNS tunnelling or exfiltration.
- Lookups of newly registered or look-alike domains by
powershell.exe,mshta.exe,rundll32.exeor Office. - Bursts of NXDOMAIN (
9003) results from one process (DGA behaviour). - Regular, periodic lookups of the same domain by a non-browser process (beaconing).
Hunt for it: Splunk & KQL
index=sysmon EventCode=22
| eval first_label=mvindex(split(QueryName, "."), 0)
| where len(first_label) > 30
| rex field=QueryName "(?<parent_domain>[^.]+\.[^.]+)$"
| stats count dc(QueryName) AS unique_queries values(Image) AS images BY host, parent_domain
| where unique_queries > 50
| sort - unique_queries// Defender for Endpoint DeviceEvents (ActionType DnsQueryResponse): long random subdomains per parent domain
DeviceEvents
| where Timestamp > ago(1d)
| where ActionType == "DnsQueryResponse"
| extend Query = tostring(parse_json(AdditionalFields).DnsQueryString)
| extend Labels = split(Query, ".")
| extend FirstLabel = tostring(Labels[0]), ParentDomain = strcat(tostring(Labels[-2]), ".", tostring(Labels[-1]))
| where strlen(FirstLabel) > 30
| summarize UniqueQueries = dcount(Query), Sample = make_set(Query, 5) by DeviceName, InitiatingProcessFileName, ParentDomain
| where UniqueQueries > 50Field names depend on your add-on and table. More translations in the Splunk vs KQL cheat sheet.
Interview question
“How would you detect DNS tunnelling on endpoints?”
✓ Strong answer sketch
DNS tunnelling encodes data in subdomain labels, so I look for many unique, long, high-entropy subdomains under a single parent domain, often with unusual record types like TXT. Sysmon Event 22 helps because it attributes each QueryName to the Image that made it, so I can tell a browser hitting a CDN from an unknown binary in ProgramData generating thousands of random labels. I would aggregate by parent domain and process, measure label length or entropy, and compare against a baseline of known CDN patterns. Then I confirm with DNS server or firewall logs, block the domain, and investigate the process.
Frequently asked questions
What are the requirements for Sysmon Event 22?
Sysmon 10 or later on Windows 8.1 / Server 2012 R2 or later, with DnsQuery enabled in the Sysmon config.
What does QueryStatus 9003 mean in Sysmon?
9003 is DNS_ERROR_RCODE_NAME_ERROR, i.e. the name does not exist (NXDOMAIN). Many of these from one process can indicate a domain generation algorithm.
Does Sysmon 22 see DNS over HTTPS?
Not when an application uses its own DoH resolver, because the lookup bypasses the Windows DNS client. Windows native DoH still goes through the DNS client and is generally captured.