Cloud DNS queries should be logged for every VPC network
This check looks at whether each VPC network in your projects has a Cloud DNS policy with query logging switched on. The safe setting is that every network is covered by a policy that logs the DNS queries made from its resources.
Why it matters
DNS is how almost everything on a network finds its way out. When a virtual machine looks up an unusual domain, that lookup is often the first trace of malware calling home, data being sent out through DNS, or a misconfigured service. Without query logs you cannot tell afterwards which workload asked for which name, so an investigation has to start from guesses.
Google describes the feature in Cloud DNS logging and monitoring. Logging is a setting on a DNS policy, and a policy is attached to one or more VPC networks.
How to check it yourself
In the Google Cloud console open Network services, then Cloud DNS, then the Policies tab. Each policy lists the networks it applies to and whether logging is on. A network that appears in no policy, or only in policies with logging off, does not log its queries. This command only reads policies:
gcloud dns policies list --project=PROJECT_ID \
--format="table(name,enableLogging,networks[].networkUrl)"
gcloud compute networks list --project=PROJECT_ID --format="value(name)"Compare the two lists: every network name from the second command should show up in a policy row where enableLogging is True. Repeat for each project in scope, ideally in a test project first.
How to fix it
In the console, open Cloud DNS, choose Policies, then Create policy (or edit an existing one), tick Logs, and select the networks to attach. A network can only be attached to one DNS policy at a time, so if it already has a policy, turn logging on in that one instead of creating a second.
Scripted version. It changes your project, so ConfigCobra never runs it for you:
# new policy for a network that has none
gcloud dns policies create dns-logging \
--description="Log DNS queries" \
--networks=NETWORK_NAME --enable-logging
# existing policy
gcloud dns policies update EXISTING_POLICY --enable-loggingQueries then appear in Cloud Logging. See the gcloud dns policies create reference for all options.
What changes when you fix it
Nothing changes for the workloads that send DNS queries. Names resolve the same way and no application needs a restart. The people affected are the security and platform teams, who now have a log to look at.
- Cloud Logging receives one entry per query, so log volume and storage use grow, most noticeably in networks with busy workloads.
- Query logs can show which internal hostnames and external domains your resources contact, so limit who can read them with logging roles.
- If a network already uses a DNS policy for another purpose, such as alternative name servers, editing that policy keeps those settings and only adds logging.
Decide the retention period and the readers of the logs before you switch it on across all networks.
Included in
| Benchmark | CIS ID | Profile |
|---|---|---|
| CIS Google Cloud Platform Foundation v5.0.0 | 2.13 | Level 1 |
More checks in Logging and Monitoring
- Configure Cloud Audit Logging across all services and usersCIS 2.1
- Enable Workspace/Cloud Identity data sharing for admin audit loggingCIS 2.2
- Configure sinks to export copies of all log entriesCIS 2.3
- Apply Bucket Lock retention policies to log-export storage bucketsCIS 2.4
- Alert on project-ownership assignments/changes via log metric filterCIS 2.5
Go further
- Logging and Monitoring17 controls in this section
- CIS Google Cloud Platform Foundation v5.0.093 controls
- CIS Google Cloud Platform Foundation checklistEvery control in one list, as CSV
- RemediationSee what a fix changes in your tenant before you apply it, then use the generated script
- Monitoring & DriftScheduled scans, drift detection and email alerts when a control regresses
Check this on your Google Cloud
ConfigCobra runs this check with every other control of the CIS Google Cloud Platform Foundation Benchmark, read-only.