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 AWS RAM and Route 53 Profiles 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".

The following diagram shows how one query moves through a rule group.

How DNS Firewall evaluates a query. Rules are checked in priority order. An ALLOW match resolves the query and stops evaluation, an ALERT match resolves it and logs it, and a BLOCK match stops resolution. A query that matches no rule is resolved normally.
The priorities and lists are an example. Placing the allow list first lets approved domains through even if a broader block list also matches them.

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.

Scenario questions

DNS Firewall configuration

Exam skills 1.4.3

Choose DNS Firewall settings for each requirement.

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

Managing at scale

DNS Firewall rule groups are shared with other accounts through AWS RAM, and associations can be deployed to every VPC with StackSets, with AWS Config rules reporting 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 a Route 53 Profile with the rule group, shared through AWS RAM and associated with every VPC by the account baseline, 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.
  • Share DNS Firewall rule groups with AWS RAM, or apply them with Route 53 Profiles, to reach every VPC.
  • Block outbound DNS to other resolvers, or workloads can bypass DNS Firewall.
  • DNS Firewall Advanced detects DNS tunnelling and domain generation algorithms.