Investigating DNS Activity with Route 53 Resolver Query Logs
This lesson explains how Route 53 Resolver query logs record which resource looked up which domain, evidence of command-and-control lookups, DNS tunnelling and exfiltration that other logs can miss.
Learning outcomes
After completing this lesson, you will be able to:
- Describe what Resolver query logs record.
- Distinguish GuardDuty DNS analysis from query logging.
- Combine query logs, flow logs and CloudTrail in an investigation.
- Configure central query logging for many accounts.
What query logs record
Almost every network connection begins with a DNS lookup, so DNS records are valuable security evidence. Malware resolves command-and-control domains, data exfiltration may use DNS itself, and the domains an instance looks up show what it tried to reach even when the connection was blocked. Route 53 Resolver query logging records the DNS queries made by resources in the VPCs associated with a query logging configuration, including queries forwarded to on-premises resolvers. The following list describes what the logs contain and where they can be sent.
- The domain, record type, response code, answers and the source instance or interface.
- Any DNS Firewall rule and action applied to the query.
- Delivery to CloudWatch Logs, S3 or Firehose.
- Configurations can be shared across accounts with AWS RAM, and Security Lake can collect the logs.
Resolver query logs
GuardDuty and DNS
GuardDuty and query logs serve different purposes. GuardDuty analyses DNS activity automatically when VPCs use the Amazon-provided resolver, without query logging being enabled, and it raises findings when instances resolve known malicious domains. GuardDuty does not, however, give the customer a searchable record of every lookup. Query logs are needed for investigation, for example to find every instance that resolved a domain later found to be malicious, or to establish when a compromised instance first contacted an attacker's infrastructure. If a VPC uses a custom DNS resolver instead of the Amazon-provided resolver, GuardDuty loses this DNS visibility, which is an important design consideration.
GuardDuty or query logs?
Using DNS logs in investigations
No single log tells the whole story of a compromised instance, but three together can. Resolver query logs show which instance looked up a suspicious domain. VPC Flow Logs show the IP address the instance then connected to, and how much data moved. CloudTrail shows which credentials were used to make API calls, such as the instance role's credentials being used to read S3. Correlating them by instance, IP address and time reconstructs the sequence of events. The following table summarises what each log contributes.
| Log | Shows |
|---|---|
| Resolver query logs | Which instance looked up a domain |
| VPC Flow Logs | Which IP address it then connected to |
| CloudTrail | Which credentials were used |
The following diagram follows a shared DNS query logging configuration from 40 accounts to the log archive.

Three logs, one story
Logging DNS for every VPC centrally
The security team needs DNS query logs from every VPC in 40 accounts, delivered to the log archive account. A query logging configuration is created once in the security account and shared through RAM:
CONFIG_ID=$(aws route53resolver create-resolver-query-log-config --name org-dns-logs \
--destination-arn arn:aws:s3:::acme-log-archive-dns \
--creator-request-id qlc-$(date +%s) --query ResolverQueryLogConfig.Id --output text)
aws ram create-resource-share --name org-dns-logs \
--resource-arns arn:aws:route53resolver:eu-west-1:333333333333:resolver-query-log-config/$CONFIG_ID \
--principals arn:aws:organizations::111111111111:organization/o-a1b2c3d4e5Each account associates its VPCs with the shared configuration, deployed by a StackSet so new VPCs are included. During an investigation, an Athena query over the bucket finds every instance that resolved a suspicious domain.
How can DNS queries from every VPC in the organisation be logged centrally?
Show answer
Share a query logging configuration through AWS RAM and associate it with each VPC.
Exam Tips
Remember for the exam
- To find out which instance looked up a domain, use Resolver query logs.
- For DNS exfiltration detection with no setup, use GuardDuty.
- Share query logging configurations through RAM to log every VPC centrally.
- Combine query logs with VPC Flow Logs and CloudTrail in investigations.
- Security Lake can collect Resolver query logs.