Lesson 3 of 4 VPC Flow Logs and Network Logging

Blocking Malicious Domains with Route 53 Resolver DNS Firewall

This lesson explains how Route 53 Resolver DNS Firewall filters the DNS queries that leave every VPC, stopping a compromised workload from reaching its controller before any connection is made.

Learning outcomes

After completing this lesson, you will be able to:

  • Configure DNS Firewall rules and actions, including AWS managed domain lists.
  • Describe how DNS Firewall is deployed across many accounts.
  • Explain how bypasses that send DNS queries to other resolvers are closed.

Rules and actions

Security groups and network ACLs filter traffic by IP address, but malware often uses domain names whose addresses change constantly. Route 53 Resolver DNS Firewall filters at the DNS level instead: it inspects the queries that resources in a VPC send to the Route 53 Resolver and can refuse to resolve domains associated with malware or command-and-control servers, so the connection never starts. Rules are grouped in rule groups that are associated with VPCs and can be deployed across accounts with AWS Firewall Manager. The following list describes its capabilities.

  • Filters outbound DNS using AWS managed domain lists (malware, botnet command and control, aggregated threats) or your own lists.
  • Actions: block (NXDOMAIN, NODATA or a custom response), alert or allow.
  • DNS Firewall Advanced rules detect DNS tunnelling and domain generation algorithm (DGA) patterns.

The following diagram shows a DNS Firewall rule group and how Firewall Manager applies it to every VPC.

A DNS Firewall rule group for every VPC. Priority 100 blocks the AWS managed malware and botnet lists with an NXDOMAIN response; priority 200 only alerts on the custom list while it is tuned. A Firewall Manager policy associates the group with every VPC, and query logs show which rule matched.
The scenario is illustrative.
True or false

DNS Firewall rules

Exam skills 3.3.1 · 1.2.6

Check how DNS Firewall rules filter queries.

Log in to try this activity Interactive activities are free with an account.

Deploying at scale

DNS Firewall protects only the VPCs its rule groups are associated with, so a single unprotected VPC leaves a gap. Three mechanisms provide coverage across many accounts. A Firewall Manager DNS Firewall policy associates rule groups with every VPC in the organisation, or in chosen accounts, and applies them automatically to new VPCs, which makes it the strongest option for consistent coverage. AWS RAM shares rule groups with chosen accounts, which then associate them themselves. Route 53 Profiles bundle DNS Firewall associations with other DNS settings, such as private hosted zones and Resolver rules, and apply them to many VPCs together. The following table summarises the options.

OptionEffect
Firewall Manager DNS Firewall policyAssociates rule groups with every VPC in the organisation, including new ones
AWS RAM sharingShares rule groups with chosen accounts
Route 53 ProfilesApplies DNS Firewall associations with other DNS settings to many VPCs
Scenario questions

DNS Firewall at scale

Exam skills 6.2.3 · 3.3.1

Choose how to deploy DNS Firewall rule groups across accounts.

Log in to try this activity Interactive activities are free with an account.

Closing bypasses

DNS Firewall sees only queries sent to the Route 53 Resolver. Security groups, network ACLs or Network Firewall should block outbound DNS to other resolvers, and the VPC's fail mode decides whether queries are blocked or allowed when the firewall cannot evaluate them.

True or false

Closing the bypasses

Exam skills 3.3.1

Check how attackers could bypass DNS Firewall and how to stop them.

Log in to try this activity Interactive activities are free with an account.
Worked example

Blocking malicious domains with DNS Firewall

The security team wants every VPC to refuse to resolve domains on AWS's malware and botnet lists, and to alert (but not block) on a custom list while it is being tuned:

RG_ID=$(aws route53resolver create-firewall-rule-group --name org-dns-protection \
  --creator-request-id rg-$(date +%s) --query FirewallRuleGroup.Id --output text)

aws route53resolver create-firewall-rule --firewall-rule-group-id $RG_ID --name block-aws-malware \
  --priority 100 --action BLOCK --block-response NXDOMAIN \
  --firewall-domain-list-id $AWS_MANAGED_MALWARE_LIST_ID --creator-request-id r1-$(date +%s)

aws route53resolver create-firewall-rule --firewall-rule-group-id $RG_ID --name alert-custom \
  --priority 200 --action ALERT \
  --firewall-domain-list-id $CUSTOM_LIST_ID --creator-request-id r2-$(date +%s)

A Firewall Manager DNS Firewall policy associates the rule group with every VPC in the organisation, including future ones. Alerts and blocks appear in Resolver query logs with the rule that matched, so the custom list can be promoted from ALERT to BLOCK once it causes no false positives.

Check yourself

Which feature detects DNS tunnelling?

Show answer

DNS Firewall Advanced.

Exam Tips

Remember for the exam

  • To stop instances resolving malicious domains, use Resolver DNS Firewall.
  • To deploy DNS Firewall rules across the organisation, use Firewall Manager.
  • To detect DNS tunnelling, use DNS Firewall Advanced.
  • Use ALERT to trial a domain list before BLOCK.
  • Block outbound DNS to other resolvers, or workloads can bypass DNS Firewall.