Configuring AWS Network Firewall for Stateful Inspection and Logging
AWS Network Firewall provides managed traffic inspection for workloads running in Amazon VPCs. It combines stateless packet filtering with stateful inspection, allowing administrators to enforce network controls across subnets, Availability Zones, transit gateways, and centralized inspection VPCs.
A reliable deployment depends on more than creating a firewall policy. Route tables must send both directions of a connection through the correct firewall endpoint, and logging must be configured before troubleshooting begins. Otherwise, a policy may appear ineffective even when its rules are correct.
The workflow below focuses on stateful rule evaluation, traffic steering, Suricata-compatible controls, and operational logging. The same principles apply whether the firewall protects a single VPC or serves as a shared inspection layer for hybrid infrastructure.
How Stateful Inspection Fits the VPC
AWS Network Firewall uses firewall policies to combine stateless rule groups, stateful rule groups, and default actions. Stateless rules are evaluated first and can allow, drop, or forward packets to the stateful engine. Stateful rules then evaluate flows using connection context, protocol details, IP addresses, ports, and application-layer information.
Stateful rule groups can use 5-tuple rules, domain list rules, or Suricata-compatible rules. A stateful engine tracks established sessions, which helps prevent return traffic from being evaluated as an unrelated connection. This behavior is especially important for TCP applications, where asymmetric routing can break inspection and produce confusing connectivity failures.
Create a dedicated firewall subnet in each Availability Zone that will process traffic. The firewall endpoint is deployed into these subnets, while application, private, public, and NAT gateway subnets use route tables that steer traffic toward the local endpoint.
Build the Policy and Rule Groups
Begin by defining the traffic that must be inspected. For outbound filtering, common controls include approved destination domains, DNS access, HTTPS traffic, software repositories, and administrative protocols. For inbound or east-west inspection, define permitted source networks, destination services, and expected ports before adding broader deny rules.
A stateful rule group can use strict order or default order evaluation. Strict order makes rule processing easier to reason about because rules are evaluated in the sequence defined by the administrator. With default order, the engine evaluates rules according to its built-in ordering behavior. Select one approach deliberately and document the expected pass, alert, and drop actions.
Suricata rules are useful when simple port filtering is insufficient. For example, an alert rule can identify a signature while allowing traffic to continue, whereas a drop rule can block a matching flow. Test custom signatures in a nonproduction policy first, since an overly broad pattern can interrupt legitimate services.
Route Every Flow Through Inspection
Deploying an endpoint does not automatically inspect traffic. Routing determines whether packets reach the firewall. In a typical egress design, the protected subnet route table sends internet-bound traffic to the firewall endpoint. The firewall subnet route table then forwards permitted traffic to a NAT gateway or internet gateway, depending on the architecture.
Return traffic must follow a compatible path back through the firewall. For a centralized design using AWS Transit Gateway, route propagation and inspection VPC route tables require careful planning. Each Availability Zone should generally use its local firewall endpoint to reduce cross-zone traffic and preserve predictable failure behavior.
Keep the inspection path symmetric. If the outbound packet crosses one endpoint and the response returns through another endpoint or bypasses the firewall, the stateful engine may reject or mishandle the session. Validate routes at every hop, including workload subnets, firewall subnets, NAT subnets, transit gateway attachments, and on-premises connectivity.
| Control Area | Typical Choice | Operational Purpose |
|---|---|---|
| Stateless rules | Allow, drop, or forward | Fast initial packet handling |
| Stateful 5-tuple rules | Source, destination, protocol, and port | Precise network-flow filtering |
| Domain list rules | Approved or denied domains | Application-aware outbound control |
| Suricata rules | Alert, pass, or drop signatures | Detailed protocol and threat inspection |
| Flow logs | Accepted and rejected sessions | Traffic visibility and troubleshooting |
| Alert logs | Stateful matches and drops | Security investigation |
| TLS logs | TLS session metadata | Encrypted traffic analysis without full payload capture |
Enable Logs Before Testing
Network Firewall supports flow and alert logging, with additional TLS logging available for supported use cases. Flow logs provide connection metadata such as source and destination details, ports, protocols, and actions. Alert logs identify stateful rule matches, including alerts and blocked traffic.
Choose a destination that matches the operational workflow. CloudWatch Logs is convenient for near-real-time searches and metric filters. Amazon S3 is well suited to long-term retention and security analytics. Kinesis Data Firehose can deliver records to downstream storage or observability platforms.
Create the destination and permissions before enabling logging. For CloudWatch, prepare a log group and confirm that the Network Firewall service can publish to it. For S3 or Firehose, verify the required bucket or delivery-stream permissions. Use separate destinations or clearly named streams for flow, alert, and TLS records so that analysts can distinguish routine traffic from security events.
Log volume can become significant in busy VPCs. Set retention policies, encryption, lifecycle rules, and access controls at the destination. Avoid sending sensitive logs to broadly accessible locations, and document which accounts or teams are authorized to query them.
Validate Stateful Behavior
Testing should cover both permitted and denied traffic. From a protected workload, test approved destinations, blocked domains, prohibited ports, DNS resolution, HTTPS connections, and expected application paths. Confirm that the traffic reaches the firewall endpoint rather than using a route that bypasses inspection.
Use VPC Flow Logs, CloudWatch queries, and firewall alert records together. VPC Flow Logs show whether packets reached an elastic network interface, while Network Firewall logs show how the inspection engine evaluated a flow. Differences between those data sources often reveal routing mistakes, missing return paths, or a rule group that was not attached to the active policy.
Check the firewall status in every Availability Zone and review endpoint health before changing rules. A healthy endpoint with no logs often indicates a route problem. Logs showing traffic but no expected rule matches may indicate an incorrect policy association, protocol mismatch, or a stateful rule group that is using a different evaluation order than expected.
Operate Rules With Change Control
Treat firewall policies as infrastructure. Store Suricata rules, policy definitions, route changes, and logging configuration in version control. Use infrastructure-as-code tools such as AWS CloudFormation, Terraform, or controlled AWS CLI workflows to make changes repeatable across environments.
Apply narrow changes and test them against known application flows. A deny rule should include a clear reason, owner, and rollback method. For high-impact policies, deploy a logging or alerting rule before enforcing a drop action. This reveals false positives without immediately interrupting production traffic.
Useful operational practices include:
- Deploy an inspection endpoint in each active Availability Zone.
- Keep firewall, NAT, transit gateway, and workload routes documented together.
- Send flow and alert logs to separate, access-controlled destinations.
- Use alert actions to tune signatures before enabling broad blocking.
- Review log retention, encryption, and delivery failures regularly.
Apply the Design to Production
A successful AWS Network Firewall deployment is the combination of policy logic, endpoint placement, symmetric routing, and usable telemetry. Stateful inspection provides meaningful session awareness, but it depends on traffic consistently traversing the same inspection path.
Start with a small protected subnet, enable flow and alert logging, and validate known-good and known-bad traffic. Then expand the policy across Availability Zones and connected networks while monitoring application behavior and firewall events. Build the configuration into your infrastructure repository and use each change as a tested, traceable deployment rather than an ad hoc console adjustment.