Secure Your AWS Resources with a Network Firewall

Securing your AWS resources and controlling network traffic is crucial for maintaining the integrity and reliability of your applications. AWS Network Firewall provides a robust solution for achieving this goal. In this tutorial, I will walk you through the process of implementing AWS Network Firewall in a detailed, step-by-step manner. 

Architecture diagram of AWS Network Firewall
Architecture diagram of AWS Network Firewall

In this scenario, I aim to achieve the following:

To host a web server on an EC2 instance and utilize AWS Network Firewall to apply specific rules. These rules include blocking ICMP (ping) requests and allowing access to a particular domain through TLS (HTTPS) connections while blocking all other outbound traffic.

Stateless Rules

  • Drop all ICMP traffic from 0.0.0.0/0 to 0.0.0.0/0
  • Forward all other traffic to the Stateful rule group

Stateful Rules

  • Allow the ssh 
  • Allowing the HTTP traffic and will only be able to access my web server using the AWS-provided DNS name.
  • Allows the outbound request from this web server to only the domain named networkproguide.com and the traffic will only be the TLS traffic.
  • Drop all other TCP traffic so that there is no other traffic that can flow in and out of my web server.

Prerequisites

Before you start the setup process, ensure you have the following:

  • A VPC.
  • Subnets: Under your VPC, create two subnets – one for the public web server and another for the firewall.
  • Internet Gateway is attached to your VPC.
  • A web server running on a public subnet. 
Web server running on a public subnet. 
Accessing web server

Step 1: Implementing AWS Network Firewall

Log in to your AWS Management Console.

Navigate to the AWS Network Firewall service.

In the AWS Network Firewall dashboard, click “Create firewall.”

Creating an AWS Network Firewall

Choose a meaningful name for your firewall.

Naming AWS Network Firewall

Choose the VPC and the subnet (private subnet) for your firewall with the availability zone.

Configuring VPC and Subnet

Configure the advanced settings as per your needs. (I have disabled the delete protection but you can enable it.)

Configuring Advanced Settings

Select “Create and associate an empty firewall policy” in the firewall policy. 

Give the name to the firewall policy and leave other things as default.

Then click on “Next.” 

Creating and associating firewall policy

Review the firewall and click on “Create firewall.” 

Creating the firewall

Wait for the firewall status to be changed to “Ready.” It can take some minutes. 

Status of the firewall

Step 2: Creating a Stateless Rule Group:

Click on “Network Firewall rule groups.”

Then click on “Create rule group.”