Ongoing service disruptions
For the most recent update on ongoing service disruptions affecting the AWS Middle East (UAE) Region (ME-CENTRAL-1), refer to the AWS Health Dashboard. For information on AWS Service migration, see How do I migrate my services to another region?
How do I configure my Network Firewall rules to block or allow specific domains?
I want to use AWS Network Firewall to filter outbound web traffic from resources in my Amazon Virtual Private Cloud (Amazon VPC).
Short description
AWS Network Firewall uses either the action order or strict evaluation order to support domain-based filtering for outbound web traffic. To configure rules, use a stateful domain list rule group or Suricata-compatible strings. Domain inspection works for HTTP and HTTPS protocols.
For HTTP, the firewall inspects the host header. For HTTPS, the firewall uses the Server Name Indication (SNI) in the TLS handshake. When you use a domain allowlist, Network Firewall sends traffic only to specified domains and drops all other requests.
Understand domain list rule group actions
Avoid combining Reject or Alert domain list rule groups with Allow domain list rule groups in a firewall policy that uses default action ordering. The default drop rule added by the Allow rule group takes effect before the Reject and Alert rules.
For more information, see Suricata compatible rule strings in AWS Network Firewall and Stateful domain list rule groups in AWS Network Firewall.
Resolution
Configure a domain list group for a policy with the default action order
Complete the following steps:
- Create a firewall.
- Open the Amazon VPC console.
- In the navigation pane, under Network Firewall, choose Network Firewall rule groups.
- Choose Create rule group, and then choose Stateful rule group as the rule group type.
- For Stateful rule group format, choose Domain list.
Note: You can't change the stateful rule order because it's inherited from the policy. The Rule order appears as Action order. - Enter a unique rule group name.
- For Capacity reservation, enter an estimated number of domains to include in the list.
Note: After you create the rule group, you can't change the value. - Under Domain list, for Domain name source, enter the domain names that you want to match. You can define domains as an exact match, such as abc.example.com. You can also define them as a wildcard, such as .example.com.
- For CIDR ranges, choose one of the following options:
For Default, choose this option when the source IP address exists in the same VPC as the firewall.
For Custom, choose this option when the source IP address exists in a remote VPC. Enter the source subnets that you want the firewall to inspect under Source IP CIDR ranges. - For Protocols, choose HTTP and HTTPS.
- For Action, choose Allow.
- (Optional) Configure Advanced settings and tags.
- Choose Create rule group.
- In the navigation pane, under Network Firewall, choose Firewall policies.
- Select the existing action order policy.
- Confirm that the default action is set to Pass.
- Under Stateful rule groups, choose Actions, and then choose Add unmanaged stateful rule groups.
- Select the rule group that you created in step 13.
Define a Suricata-compatible IPS rule for a policy with the action order evaluation
Complete the following steps:
- Create a firewall.
- Open the Amazon VPC console.
- In the navigation pane, under Network Firewall, choose Network Firewall rule groups.
- Choose Create rule group, and then choose Stateful rule group as the rule group type.
- For Stateful rule group format, choose Suricata Compatible rule string.
Note: You can't change the stateful rule order because it's inherited from the policy. The Rule order appears as Action order. - Enter a unique rule group name.
- For Capacity reservation, enter an estimated number of domains to include in the list.
Note: After you create the rule group, you can't change the value. - (Optional) Define custom rule variables to use in the Suricata signatures.
- (Optional) Define IP set references to use in the Suricata signatures.
- Under Suricata compatible rule string, enter the following rules:
Note: In the preceding rules, replace the domains with the domains that you want to include.pass http $HOME_NET any -> $EXTERNAL_NET any (http.host; dotprefix; content:".amazonaws.com"; endswith; msg:"matching HTTP allowlisted FQDNs"; flow:to_server, established; sid:1; rev:1;) pass http $HOME_NET any -> $EXTERNAL_NET any (http.host; content:"example.com"; startswith; endswith; msg:"matching HTTP allowlisted FQDNs"; flow:to_server, established; sid:2; rev:1;) pass tls $HOME_NET any -> $EXTERNAL_NET any (tls.sni; dotprefix; content:".amazonaws.com"; nocase; endswith; msg:"matching TLS allowlisted FQDNs"; flow:to_server, established; sid:3; rev:1;) pass tls $HOME_NET any -> $EXTERNAL_NET any (tls.sni; content:"example.com"; startswith; nocase; endswith; msg:"matching TLS allowlisted FQDNs"; flow:to_server, established; sid:4; rev:1;) drop http $HOME_NET any -> $EXTERNAL_NET any (http.header_names; content:"|0d 0a|"; startswith; msg:"not matching any HTTP allowlisted FQDNs"; flow:to_server, established; sid:5; rev:1;) drop tls $HOME_NET any -> $EXTERNAL_NET any (msg:"not matching any TLS allowlisted FQDNs"; flow:to_server, established; sid:6; rev:1;) - (Optional) Configure Advanced settings and tags.
- Choose Create rule group.
- In the navigation pane, under Network Firewall, choose Firewall policies.
- Select the existing action order policy.
- Confirm that the default action is set to Pass.
- Under Stateful rule groups, choose Actions, and then choose Add unmanaged stateful rule groups.
- Select the rule group that you created in step 12.
Note: Domain rules include the established flow keyword, but it might not account for all out-of-flow packet exchange edge cases. Before you use an example rule listing, test the rule to verify that it works as expected.
Configure a domain list rule group for a policy with the strict evaluation order
Complete the following steps:
- Create a firewall.
- Open the Amazon VPC console.
- In the navigation pane, under Network Firewall, choose Network Firewall rule groups.
- Choose Create rule group, and then choose Stateful rule group as the rule group type.
- For Stateful rule group format, choose Domain list.
Note: You can't change the stateful rule order because it's inherited from the policy. The Rule order appears as Strict. - Enter a unique rule group name.
- For Capacity reservation, enter an estimated number of domains to include in the list.
Note: After you create the rule group, you can't change the value. - Under Domain list, for Domain name source, enter the domain names that you want to match. You can define domains as an exact match, such as abc.example.com. You can also define them as a wildcard, such as .example.com.
- For CIDR ranges, choose one of the following options:
For Default, choose this option when the source IP address exists in the same VPC as the firewall.
For Custom, choose this option when the source IP address exists in a remote VPC. Enter the source subnets that you want the firewall to inspect under Source IP CIDR ranges. - For Protocols, choose HTTP and HTTPS.
- For Action, choose Allow.
- Choose Create rule group.
- In the navigation pane, under Network Firewall, choose Firewall policies.
- Select the existing strict order policy.
- For Stateful rule evaluation order and default actions, choose Edit.
- For Default actions, choose Drop established.
- Choose Save.
Define a Suricata-compatible IPS rule for a policy with a strict evaluation order
Complete the following steps:
- Create a firewall.
- Open the Amazon VPC console.
- In the navigation pane, under Network Firewall, choose Network Firewall rule groups.
- Choose Create rule group, and then choose Stateful rule group as the rule group type.
- For Stateful rule group format, choose Suricata Compatible rule string.
Note: You can't change the stateful rule order because it's inherited from the policy. The Rule order appears as Strict. - Enter a unique rule group name.
- For Capacity reservation, enter an estimated number of domains to include in the list.
Note: After you create the rule group, you can't change the value. - (Optional) Define custom rule variables to use in the Suricata signatures that you define.
- (Optional) Define IP set references to use in the Suricata signatures that you define.
- Under Suricata compatible rule string, enter the following rules:
Note: In the preceding rules, replace the domains with the domains that you want to include.pass http $HOME_NET any -> $EXTERNAL_NET any (http.host; dotprefix; content:".amazonaws.com"; endswith; msg:"matching HTTP allowlisted FQDNs"; flow:to_server, established; sid:1; rev:1;) pass http $HOME_NET any -> $EXTERNAL_NET any (http.host; content:"example.com"; startswith; endswith; msg:"matching HTTP allowlisted FQDNs"; flow:to_server, established; sid:2; rev:1;) pass tls $HOME_NET any -> $EXTERNAL_NET any (tls.sni; dotprefix; content:".amazonaws.com"; nocase; endswith; msg:"matching TLS allowlisted FQDNs"; flow:to_server, established; sid:3; rev:1;) pass tls $HOME_NET any -> $EXTERNAL_NET any (tls.sni; content:"example.com"; startswith; nocase; endswith; msg:"matching TLS allowlisted FQDNs"; flow:to_server, established; sid:4; rev:1;) - (Optional) Configure Advanced settings and tags.
- Choose Create rule group.
- In the navigation pane, under Network Firewall, choose Firewall policies.
- Select your strict order policy.
- For Stateful rule evaluation order and default actions, choose Edit.
- For Default actions, choose Drop established.
- Choose Save.
Note: Domain rules include the established flow keyword. This keyword might not capture all edge cases where packets are exchanged outside of normal connection flows. Before you use an example rule listing, test the rule to verify that it works as expected.
Test your configurations
To test that your configurations work, run curl commands to the specified domains.
The following example command tests HTTPS access to the https://example.com domain:
curl -v --silent https://example.com --stderr - | grep 200
If access is allowed, then you receive the following output:
< HTTP/2 200
The following example command tests HTTP access to https://www.google.com:
curl -v http://www.google.com
The following example output shows that firewall rules are blocking HTTP traffic because the connection stops at the GET request:
* Trying [IP_ADDRESS]... * Connected to www.google.com ([IP_ADDRESS]) port 80 (#0) > GET / HTTP/1.1 > Host: www.google.com > User-Agent: curl/7.79.1 > Accept: */*
The following example command tests HTTPS access to https://www.google.com:
curl -v https://www.google.com
The following example output shows that HTTPS traffic is blocked because the connection stops during the TLS handshake:
* Trying [IP_ADDRESS]... * Connected to www.google.com ([IP_ADDRESS]) port 443 (#0) * ALPN, offering h2 * ALPN, offering http/1.1 * TLSv1.2 (OUT), TLS header, Certificate Status (22): * TLSv1.2 (OUT), TLS handshake, Client hello (1):
Related information
Firewall policies in AWS Network Firewall
Creating a stateful rule group
Examples of stateful rules for AWS Network Firewall
- Language
- English

Relevant content
- asked a year ago
- asked 2 years ago
AWS OFFICIALUpdated 13 days ago