Lesson 4 of 6 Hybrid DNS and Network Security

Filtering DNS Queries with Route 53 Resolver DNS Firewall

This lesson explains how filtering DNS queries at Route 53 Resolver gives a central control point against command-and-control and exfiltration through DNS, protecting every workload without changing any of them.

Learning outcomes

After completing this lesson, you will be able to:

  • Describe rule groups, domain lists and actions.
  • Choose between fail open and fail closed.
  • Explain how RAM and Firewall Manager manage DNS Firewall at scale.

Rules and actions

DNS Firewall applies rule groups to queries leaving a VPC through the Resolver. Each rule matches a domain list and takes an action.

Rules are evaluated in priority order, and three actions are available. ALLOW resolves the query normally and stops evaluating, so an allow list of approved domains placed ahead of a broad block lets them through. ALERT resolves the query and logs it, which is how a new list is trialled before it is enforced. BLOCK stops resolution for known malicious or unapproved domains, returning NODATA, NXDOMAIN or an override answer that points to a safe address. The following table summarises the actions.

ActionEffectUse
ALLOWResolve normally and stop evaluatingAllow-list approved domains ahead of a broad block
ALERTResolve and logTrial a new list before enforcing it
BLOCKReturn NODATA, NXDOMAIN or an override answerKnown malicious or unapproved domains

AWS managed domain lists cover malware, botnet command-and-control and other threats. DNS Firewall Advanced adds detection of DNS tunnelling and domain generation algorithms, which static lists cannot catch. For a strict environment, ALLOW the domains workloads need and BLOCK * at a lower priority, a "walled garden".

Fail open or fail closed

If DNS Firewall cannot evaluate a query, the VPC's fail mode decides the outcome. Fail closed (the default) blocks the query, favouring security; fail open lets it through, favouring availability. Scenarios that stress availability over strict filtering point to fail open.

Managing at scale

DNS Firewall rule groups are shared with other accounts through AWS RAM, or applied by AWS Firewall Manager, which associates them with every VPC in the organisation, including new ones, and reports VPCs that are not protected. Route 53 Profiles can also carry rule group associations to many VPCs together with other DNS settings.

DNS Firewall is one layer of defence. It stops the lookup, while Network Firewall stops connections, including those made directly to IP addresses or filtered by TLS SNI, so the two are used together. DNS Firewall also sees only queries sent to the Route 53 Resolver; a workload that sends queries to another resolver on the internet bypasses it. Outbound TCP and UDP port 53 to anything other than the Resolver is therefore blocked with security groups, network ACLs or Network Firewall.

Worked example

A security team finds that compromised instances in several accounts resolved randomly-generated domain names before beaconing out. They want to block this behaviour in every current and future VPC in the organisation.

The organisation-wide requirement points to Firewall Manager policies for DNS Firewall, so new VPCs are covered automatically. Randomly generated names point to DNS Firewall Advanced's DGA protection rather than a static list, deployed first with ALERT to measure false positives and then with BLOCK.

Check yourself

What is the trade-off between fail open and fail closed for DNS Firewall?

Show answer

Fail open keeps DNS resolution working if the firewall cannot evaluate a query, favouring availability. Fail closed blocks the query in that case, favouring security.

Exam Tips

Remember for the exam

  • DNS Firewall filters queries through the Route 53 Resolver: ALLOW, ALERT or BLOCK per domain list.
  • Use ALERT to trial rules; use ALLOW plus BLOCK * for a walled garden.
  • Fail closed favours security; fail open favours availability.
  • Firewall Manager applies DNS Firewall rule groups to every VPC in the organisation.
  • Block outbound DNS to other resolvers, or workloads can bypass DNS Firewall.
  • DNS Firewall Advanced detects DNS tunnelling and domain generation algorithms.