Skip to Content
Asterrr's Handbook
3 · Infrastructure security

Egress Filtering and Domain Allow Lists

Restrict outbound traffic to approved domains with Network Firewall, Route 53 Resolver DNS Firewall, or a self-managed proxy.

Exam tasks: 3.3 (network controls that permit or prevent traffic; north/south and east/west protection)

The decision: must outbound traffic reach only approved destinations, and at which layer do you enforce that?

Security groups and NACLs filter by IP and port, never by domain name. To let workloads reach only approved sites, filter at the DNS layer, at an inline network firewall, or at a proxy. An allow list denies everything by default, which is stricter than a block list.

VPCPrivate subnetFirewall subnetPublic subnetDNS queryroute tableWorkloadNetwork FirewallendpointNAT gatewayDNS FirewallInternet gatewayApproved sites
Private workloads send DNS through the VPC resolver, where DNS Firewall applies. Routed traffic crosses a Network Firewall endpoint before the NAT gateway.

Options compared

OptionLayerStrengthLimit
Route 53 Resolver DNS FirewallDNSAllow, block or alert on domain lists. Managed domain lists. Advanced rules for DGA and DNS tunneling. Applies to VPC and on-premises queries that come through the VPC resolverFilters DNS names only. Does not filter HTTPS, SSH or other protocols. A client that hard-codes an IP or uses another resolver is not covered
AWS Network FirewallL3 to L7Stateless and stateful rules, Suricata-compatible IPS rules, domain filtering, deep packet inspection, protocol detection regardless of portNeeds dedicated firewall subnets and route table changes. Endpoint cannot inspect its own subnet
Self-managed proxy (Squid, Varnish)HTTP/HTTPSDomain allow list and content filteringYou run and patch the EC2 instance
Security group or NACLL3/L4Cheap and fastNo domain awareness

Egress patterns by effort

PatternWhat it gives youEffort
No route to the internet (isolated subnets + VPC endpoints)Strongest. Nothing leaves except to AWS servicesLow, if workloads only need AWS APIs
NAT gateway aloneHides private IPs. Filters nothingLow
Network Firewall (central egress VPC) with domain listsFQDN allow list, IPS signatures, logsMedium
Explicit forward proxy fleet (for example Squid) behind an NLBURL-level allow list, user auth, cachingHigh, because you patch and scale it
GWLB + vendor firewallVendor URL categories and threat feedsHigh
  • An explicit proxy only filters clients configured to use it. Pair it with security groups or NACLs that stop direct outbound 80/443, or clients just go around it.
  • Use VPC endpoints with endpoint policies so traffic to AWS services never reaches the egress path. See VPC network controls.

DNS Firewall behavior

  • Rule groups attach to a VPC. Rules and rule groups are processed from the lowest priority number up, and evaluation stops at the first match.
  • Rule actions are allow (domain lists only), block and alert. Blocked queries can get a custom response.
  • If DNS Firewall cannot answer, the resolver fails closed and blocks the query by default. The VPC fail mode is configurable.
  • It is regional. A rule group can be shared with other accounts, and Firewall Manager can manage DNS Firewall policies across an organization.

Network Firewall behavior

  • You create a firewall, a firewall policy and rule groups. Endpoints live in a firewall subnet in each Availability Zone.
  • Route tables steer traffic through the endpoint, typically between the internet gateway or NAT gateway and the protected subnets.
  • A firewall policy can reference stateless and stateful rule groups.
  • TLS inspection uses an ACM certificate to decrypt and re-encrypt traffic.
  • Firewall Manager manages firewalls across an organization.

Self-managed proxy pattern

  1. Run Squid or Varnish on an EC2 instance in a public subnet.
  2. Allow inbound ports 80 and 443 from the private subnet.
  3. Point the private subnet's route to the proxy instance for internet traffic.
  4. Disable the source/destination check on the proxy ENI because it forwards traffic not addressed to itself.

Exam signal

"Allow outbound HTTPS only to a list of vendor domains" means Network Firewall with a domain list rule. "Block malware command and control domains for all VPCs" means DNS Firewall with a managed domain list.

Exam trap

DNS Firewall only sees queries sent through the Route 53 VPC resolver. Traffic to a raw IP address bypasses it, and so does DNS to a third-party resolver. Pair it with Network Firewall or a deny-by-default egress route.

Scenarios

Scenario
An analytics company runs batch jobs in private subnets that must download packages only from pypi.org and files.pythonhosted.org over HTTPS. All other outbound internet traffic must be blocked and logged. Traffic leaves through NAT gateways. The team doesn't want to run proxy servers. What should the security engineer implement?

Further reading

On this page