A DNS Threat-Hunting Workflow for Small Teams
Alerts are things that find you. Hunting is going to look. The difference matters because alerts only fire for patterns someone already wrote a rule for. The things that hurt small organizations most are usually the ones nobody wrote a rule for yet. Examples include a machine quietly resolving a name it has no business knowing or a device that stopped using your resolver last month. Another example is a burst of failed lookups that never crossed any threshold. None of those pages you. All of them are sitting in your DNS query log right now, waiting for someone to ask.
This guide gives you a hunt you can actually keep doing: thirty minutes, once a week. It includes a fixed set of six questions asked of the query log and the firewall's deny log. There is an investigation sequence for anything that stands out, and a simple way to record what you found. A loop turns each finding into a better blocklist or a sharper rule. This guide is written for a team of one to three people who also have everything else to do. It assumes the sensor exists. If not, begin with turning your resolver into a sensor and come back when a week of log is in the collector.
In this guide
- Why thirty minutes a week is enough to start
- What you need before the first hunt
- The six fixed queries
- The investigation sequence for a finding
- Recording hunts and outcomes
- Feeding findings back into lists and rules
- Questions to add once the six are routine
- Keeping the sensor itself healthy
- The weekly hunt checklist
- Where to go next
Why thirty minutes a week is enough to start
Hunting has a reputation as something large security teams do with dedicated analysts and expensive platforms. The reputation is not wrong, but it describes the top of the ladder, not the first rung. The first rung is a person, a search box, and a list of questions that get asked the same way every week. The value comes from repetition rather than cleverness. The fifth time you run the "rarest domains" report, you know what it normally contains, and the one new line jumps out in seconds. A hunt that runs every week with six fixed queries beats an ambitious one that runs twice and is abandoned.
Fixed questions also solve the blank-page problem. "Go look for bad things in the DNS log" is paralyzing; "run query three and read the top twenty lines" is a task. Over time you will add questions of your own, and some weeks a finding will eat the whole half hour and then some. That is fine. The floor is thirty minutes and six queries; the ceiling is whatever the week demands.
What you need before the first hunt
- A parsed query log in a searchable collector is needed, with client, name, record type, response code, and answer as separate fields. It needs at least a week of history. More history makes the "first seen" and "rare" questions far stronger.
- A way to turn an address into a person or a role. DHCP lease history, an asset inventory, or the directory's computer objects. Without this, every finding stalls at "some machine."
- The firewall's deny log, specifically outbound denials on the DNS port, so you can see who is trying to go around your resolver.
- A hunt log. A shared document, a spreadsheet, or a folder of dated notes. Its format matters far less than its existence.
- An allowlist of known-benign names for each query, started empty and grown week by week, so the reports get shorter as your knowledge grows.
Save each of the six queries in your collector as a named report. The whole point is that next week you click, not type.
The six fixed queries
The sketches below are generic pseudo-queries; translate them into whatever your collector speaks. Each covers the last seven days and groups by client or by registered domain (the part of a name someone actually owns). It returns a short list you read top to bottom. For every one, the questions are the same: what is normally here, and what is new?
1. Top NXDOMAIN sources
FROM dns_log WHERE window = last 7d AND rcode = 'NXDOMAIN' SELECT client, COUNT(*) AS failures, COUNT(DISTINCT qname) AS distinct_names GROUP BY client ORDER BY distinct_names DESC LIMIT 20
Normal: your monitoring server and a few misconfigured applications, failing on the same handful of names every week. Stands out: a client new to this list, or one whose distinct failed names are in the hundreds with random-looking shapes. The second is the domain-generation pattern described in beaconing and domain-generation patterns; the first is usually a misconfiguration worth a ticket.
2. Longest names
FROM dns_log WHERE window = last 7d SELECT client, qname, LENGTH(qname) AS len, registered_domain(qname) AS domain WHERE domain NOT IN allowlist_long_names ORDER BY len DESC LIMIT 30
Normal: content delivery and cloud-service names from many clients, which you allowlist by domain as you recognize them. What stands out is one client, one unfamiliar domain, and labels near the length limit and different on every line. That is the tunneling shape from recognizing data smuggled in queries.
3. Rarest domains (resolved by one client only)
FROM dns_log WHERE window = last 7d AND rcode = 'NOERROR'
SELECT registered_domain(qname) AS domain,
COUNT(DISTINCT client) AS clients,
ANY(client) AS the_client,
COUNT(*) AS queries
GROUP BY domain
HAVING clients = 1 AND queries > 20
ORDER BY queries DESC
LIMIT 30
Normal: niche business tools used by one person, and the occasional personal service. Stands out: a rare domain with a high query count, a regular rhythm when you look at the individual lines, or a name that looks generated. The queries > 20 floor keeps one-off visits out; adjust it to whatever makes the list readable.
4. Newest first-seen domains per client
-- requires the first_seen table built from log history
FROM first_seen WHERE first_seen_at within last 7d
SELECT domain, first_seen_at, first_seen_by AS client,
(SELECT COUNT(DISTINCT client) FROM dns_log
WHERE registered_domain(qname) = domain) AS clients_now
ORDER BY first_seen_at DESC
Normal: a stream of new marketing sites, news links, and newly adopted tools, most of which several clients resolve within days. What stands out is a domain first seen this week that is still resolved by only one client. That is especially true when it is also on the rare list or the long-name list. Two signals together are what earn a closer look. New domains that turn out to be new cloud tools are a different kind of finding. The guide on finding unsanctioned SaaS covers what to do with those.
5. Clients with the highest unique-domain counts
FROM dns_log WHERE window = last 7d SELECT client, COUNT(DISTINCT registered_domain(qname)) AS domains, COUNT(*) AS queries GROUP BY client ORDER BY domains DESC LIMIT 20
Normal: proxies, mail servers, and heavy browsers at the top, in roughly the same order every week. Stands out: a server that should talk to a dozen domains suddenly talking to hundreds, or a workstation that jumped several places up the list. Breadth is the signal here; a machine exploring the Internet that has no reason to is worth asking about.
6. Queries bypassing the resolver
FROM firewall_log WHERE window = last 7d AND action = 'deny' AND direction = 'outbound' AND dst_port = 53 AND src NOT IN internal_resolvers SELECT src, dst, COUNT(*) AS attempts GROUP BY src, dst ORDER BY attempts DESC
This one reads the firewall, not the resolver, and it is the hunt's honesty check. Every line is a device that tried to resolve names somewhere you cannot see. Normal: a few devices with hard-coded public resolvers, which you fix. Stands out: a client that suddenly started, or one hammering an unfamiliar destination. Where you can, add denials to well-known encrypted-DNS endpoints as a second view. A short list here means the sensor is complete; a long one means the other five queries are missing part of the network.
Tip: read each report top to bottom, but stop at the first line you cannot explain and investigate it before moving on. Twenty lines you understand are worth nothing; one line you do not is the whole hunt.
The investigation sequence for a finding
Something stood out. Most findings take five minutes to close; a few take the afternoon. Either way, follow the same path so nothing is skipped and the notes come out consistent.
- Client. Turn the address into a hostname, then into a role: whose workstation, which server, what device. Note whether it is managed and whether it has endpoint logging. An address you cannot account for at all is a finding on its own.
- User and role. If it is a person's machine, would this activity make sense for their job? A developer resolving odd names is routine; a shared kiosk doing it is not. If in doubt, a two-line message asking "did you use anything new this week?" is quick, polite, and often closes the case.
- Timeline. Search the query log for the client-and-domain pair as far back as retention allows. When did it start? Is it continuous, scheduled, or a single burst? Find the first line; that timestamp is your anchor for every other log.
- Other clients. Search the whole log for the same domain and for the addresses it resolved to. One machine is an investigation; three that share nothing but this name is an incident.
- Other logs. Around the anchor time, look at the firewall for connections to the answered addresses. For that same time, look at the proxy for what was requested, and at the endpoint for new processes, scheduled tasks, or installs.
- Decide. Choose one of three outcomes, always recorded. If it is benign, add to the relevant allowlist with a reason. If you block, add the name to the local blocklist and sinkhole it, and keep watching the client. If you escalate, isolate the client, preserve it, and hand it to your incident process.
The middle outcome deserves a word. Blocking and sinkholing a name you are unsure about is cheap and reversible. The sinkholes and blocklists guide explains how the sinkhole then tells you which other clients try to reach it. What you should not do is block and forget. A blocked name with an unexplained client behind it is a question you have postponed, not answered. It belongs on next week's hunt list until it is closed.
Recording hunts and outcomes
Write down every hunt, including the ones where nothing happened. A record of "ran all six, nothing new, allowlisted two content-delivery domains" is not wasted. It is the baseline that makes next month's odd line odd. Keep the entries short and identical in shape so they can be scanned. An illustrative entry:
Hunt: week 14 — 32 min — run by: JM Q1 NXDOMAIN: usual (mon01, app-srv-3). New: ws-0417, 340 distinct names, random-looking. Q2 long names: nothing new after allowlisting cdn-static.example (many clients). Q3 rare: fin-lt-02 -> portal.supplier.example (accountant, confirmed, allowlisted). Q4 first-seen: 9 new; 8 shared by many clients; 1 = ws-0417 -> hxmqtlzpvcek.example Q5 unique-domain: unchanged. Q6 bypass: printer-3f still using a public resolver (ticket 8812 open). Finding F-31: ws-0417 (reception PC) NXDOMAIN storm + one resolving generated name, started Tue 03:00. Sinkhole hit confirmed. Outcome: ESCALATE. Isolated, ticket 8815. Fed back: domain + address added to local blocklist; NXDOMAIN threshold rule added.
Notice what the entry captures: which queries ran, what was normal, and what was new. For each finding, it captures a decision and what changed because of it. Give findings a running number so a later entry can say "same as F-31." Over a year this log becomes the most honest description of your network's behavior you will ever own. It is also the first thing a new colleague should read.
Feeding findings back into lists and rules
A hunt that only produces notes is a diary. The loop closes when each finding changes something, so the next week's hunt is shorter and the network is safer:
- Benign findings become allowlist entries, per query, by domain, with a reason and a date. This is how the reports shrink. Review the allowlists every few months and remove entries whose reason has expired.
- Bad names become blocklist entries in the local list on your resolver, sinkholed, immediately. Include the addresses they resolved to in a firewall block where practical, since names can change but the infrastructure often lingers.
- Repeated patterns become alert rules. When a hunt query surfaces the same kind of finding more than once, promote it. Examples include an NXDOMAIN storm from a single client, a first-seen domain resolved by exactly one machine, or a client appearing in the bypass log. Rules catch tomorrow what the hunt caught today, and the hunt moves on to what rules cannot express yet.
- Misconfigurations become tickets. Half of what a hunt finds is orphaned applications, retired endpoints, and devices with hand-typed DNS settings. None of it is an attack, all of it is noise in your sensor, and fixing it makes the next hunt cleaner.
Questions to add once the six are routine
After a couple of months the six queries will run quickly and their allowlists will be mature. That is the moment to add a seventh, and the best candidates come from your own network rather than from a list. A few that small teams find productive:
- Servers resolving outside their expected set. A file server, a domain controller, or a database host should resolve a short, stable list of names. Keep that list per server and report anything outside it. Servers change rarely, so the report is nearly empty until the day it is not.
- After-hours activity from workstations. Lookups between midnight and dawn from machines whose owners were asleep. Updates and backups account for most of it; what remains is worth a glance.
- Record-type ratios per client. The share of each client's queries that are not simple address lookups, compared with the network norm. Mail servers top it legitimately; a workstation joining them is the signal.
- Names that resolved to a new address this week. A domain your network has used for years whose answer changed abruptly may have moved to a new host, or may have been taken over. Usually the former; occasionally the latter.
Add one at a time. Run it as a report for a few weeks before you trust it. Retire any question that has not produced a finding in months. The hunt should stay short enough that skipping a week feels like a loss rather than a relief.
Keeping the sensor itself healthy
The hunt has a silent failure mode. The log stops arriving and the reports come back short and clean. And a short, clean report looks exactly like a good week. Guard against it with two checks at the start of every hunt. First, confirm the line count per resolver for the past seven days is in the usual range, and that every resolver appears. A resolver missing from the log, or one whose volume fell off a cliff mid-week, is the first finding, before any threat. Second, run a lookup for a name you invent on the spot. Confirm it appears in the collector within a minute, with your client address on it.
The broader question of whether the resolvers themselves are answering correctly and quickly is an operations matter with its own checks and thresholds. Those are covered in monitoring DNS health. The hunt cares about a narrower thing: that every query the resolver answered was also written down and delivered. Alert on a resolver whose log rate drops to zero and on collector disk space. Then you will never again spend a calm half hour admiring an empty report from a dead pipeline.
The weekly hunt checklist
| Step | What to do | Looking for | Typical time |
|---|---|---|---|
| 0. Sensor check | Line counts per resolver; test lookup appears in the collector | Missing resolvers, volume cliffs, broken pipeline | 2 min |
| 1. Top NXDOMAIN sources | Run saved query; compare with last week | New clients; hundreds of distinct random names | 4 min |
| 2. Longest names | Run; allowlist recognized domains | One client, one unfamiliar domain, labels near the limit | 4 min |
| 3. Rarest domains | Run; skim domain names and query counts | High count or regular rhythm from a single client | 4 min |
| 4. Newest first-seen per client | Run; note which are still single-client | New and rare together | 4 min |
| 5. Highest unique-domain counts | Run; compare ranking with last week | Servers exploring; workstations that jumped up | 3 min |
| 6. Resolver bypass | Run against the firewall deny log | New devices; unfamiliar destinations | 3 min |
| 7. Investigate | Client, user, timeline, other clients, other logs, decide | Benign, block, or escalate; nothing left undecided | as needed |
| 8. Record and feed back | Write the hunt entry; update allowlists, blocklist, rules, tickets | Every finding changed something | 4 min |
The times are a guide for a network where the allowlists are already mature. The first few hunts will run long as you learn what normal looks like. That is the investment. After a month, most weeks really do fit in thirty minutes, and the weeks that do not are the weeks the hunt earned its keep.
Where to go next
You now have a hunt that fits a small team's week. It includes six saved queries, a sensor check that keeps you honest, and an investigation path that always ends in a decision. It also includes a log entry that captures what changed, and a loop that turns findings into allowlists, blocklists, alert rules, and tickets. Everything the hunt looks for is explained in depth elsewhere in this topic. The sensor itself is covered in DNS query logging. The patterns are covered in tunneling and beaconing and domain generation. The response side is covered in sinkholes and blocklists. All of it is collected at DNS as a Threat Sensor.
Put this into practice with SysPeep Monitor
Step zero of every hunt is checking that the resolvers and the collector are alive. That is exactly the kind of check that should run itself. SysPeep Monitor watches your DNS servers, log collector, and the disks and services under them. Its alert rules and dependencies are designed to tell you about a real outage without drowning you in noise. The free trial installs on a Windows machine in minutes.
Download Free TrialLearn About SysPeep