A week of DNS logs from a mid-sized office can run to millions of lines. Reading them is not an option. What you can do is reduce every host to a couple of numbers and look at the outliers.
What a DGA leaves behind
Some malware does not carry a fixed address for its command server, because a fixed address is easy to block. Instead it runs a domain generation algorithm: a formula, seeded by something like the date, that outputs a long list of pseudo-random domain names. The operator registers a few of them. The malware tries them in turn until one answers.
That means almost every attempt fails. A failed lookup returns NXDOMAIN, and the resolver logs it.
Signal one: NXDOMAIN rate per host
Group the log by client and count NXDOMAIN responses. Ordinary workstations produce a few a day, from typos and dead bookmarks. A host producing hundreds stands out immediately.
Count distinct failing names, not just failures. One misconfigured client retrying the same bad name 500 times has a high count and no variety. A DGA host has a high count and hundreds of different names.
Signal two: label entropy
Entropy measures how unpredictable the characters in a string are. For a domain label such as kq3vx9z2p1ml, the characters are close to uniformly random, so the score is high. For intranet or mail, it is low because the letters follow human language.
A short Python function is enough:
import math from collections import Counter def entropy(s): c = Counter(s) return -sum(n/len(s) * math.log2(n/len(s)) for n in c.values()) Apply it to the leftmost label of each failing query and average per host.
Why you need both
Each signal alone misleads. A high NXDOMAIN rate happens with broken software. High entropy happens with some legitimate services, since certain CDN and tracking hostnames use random-looking labels. A host with many distinct failing names and high average entropy is a much better lead.
What to do next
A flagged host is a hypothesis. Find the process that issued the queries, check when the pattern began, and look for any generated name that did resolve, because that is the one the malware reached. Then write down what you saw and what you ruled out. The SOC investigation notes post shows one way to build that timeline and hand it over.
Try it on data
The DNS log analysis lab on Codelivly gives you a week of corporate DNS logs and asks you to find the DGA-infected host using NXDOMAIN rate and label entropy. If you are working toward analyst roles, the SOC Analyst Level 1 career path is the longer route from network basics into alert investigation.

