Cloud Firewalls vs Network Security Groups: How to Secure Workloads

Network security groups and security groups are built-in, stateful packet filters that allow or deny traffic to individual cloud resources by IP, port and protocol. Cloud firewalls such as AWS Network Firewall, Azure Firewall and Google Cloud NGFW are managed network firewalls that inspect traffic for a whole network with features like domain filtering, intrusion prevention and TLS inspection.

Jul 26, 2025 - 14:13
Updated: 
102.4k

Network Security in Cybersecurity & Ethical Hacking · Explainer

Cloud & Container Security, Cloud Computing: AWS, Azure & GCP

Cloud Firewalls vs Network Security Groups: How to Secure Workloads

Quick answer: Network security groups and security groups are built-in, stateful packet filters that allow or deny traffic to individual cloud resources by IP, port and protocol. Cloud firewalls such as AWS Network Firewall, Azure Firewall and Google Cloud NGFW are managed network firewalls that inspect traffic for a whole network with features like domain filtering, intrusion prevention and TLS inspection. Use security groups or NSGs on every workload as the first layer, and a cloud firewall at network boundaries for central control of internet, inter-network and on-premises traffic.

Key takeaways

  • Security groups and NSGs are free, per-resource and stateful; they are the minimum.
  • AWS network ACLs are stateless subnet filters; use them sparingly.
  • Managed cloud firewalls add inspection and central policy, at extra cost.
  • Never allow SSH (22) or RDP (3389) from 0.0.0.0/0.
  • Reference other security groups or tags instead of IP lists where possible.

Table of Contents

What Are the Layers of Cloud Network Filtering?

  1. Resource level: AWS security groups, Azure NSGs on NICs, Google Cloud firewall rules targeted by tag or service account.
  2. Subnet level: AWS network ACLs, Azure NSGs on subnets.
  3. Network boundary: AWS Network Firewall, Azure Firewall, Google Cloud NGFW, or third-party virtual appliances.
  4. Application layer: web application firewalls in front of HTTP services.

This layering is defence in depth: a mistake in one layer is caught by another.

How Do Security Groups and NSGs Work?

AWS security groups attach to network interfaces. They only contain allow rules, are stateful (return traffic is automatically allowed), and can reference other security groups as sources. Network ACLs apply to subnets, are stateless, support deny rules and are evaluated in number order.

Azure NSGs attach to subnets or NICs. Rules have priorities from 100 to 4096 (lower runs first), support allow and deny, and are stateful. Default rules allow traffic within the virtual network and from the Azure load balancer, and deny other inbound traffic. Application security groups let you group VMs by role. See the Azure NSG overview.

Google Cloud VPC firewall rules apply to the whole VPC network and target instances by network tag or service account. They are stateful with priorities from 0 to 65535. Hierarchical and network firewall policies, part of Cloud NGFW, let organisations enforce rules across projects.

What Do Managed Cloud Firewalls Add?

  • Central policy for many networks, often in a hub network.
  • Outbound filtering by domain name (FQDN), such as allowing only *.ubuntu.com for updates.
  • Intrusion detection and prevention signatures.
  • TLS inspection in premium tiers.
  • Logging of allowed and denied flows for investigations.

Examples: AWS Network Firewall, Azure Firewall and Google Cloud NGFW Enterprise.

How Do They Compare Across AWS, Azure and Google Cloud?

AWSAzureGoogle Cloud
Per-resource filterSecurity groupNSG on NICFirewall rule by tag or service account
Subnet filterNetwork ACL (stateless)NSG on subnetNot separate; rules are network-wide
Deny rulesNo in SGs; yes in NACLsYesYes
Grouping by roleSG referencesApplication security groupsTags, service accounts
Managed firewallAWS Network FirewallAzure FirewallCloud NGFW
Flow logsVPC Flow LogsVNet flow logsVPC Flow Logs, firewall rules logging

What Does a Three-Tier Design Look Like?

TierAllow inbound fromPorts
Load balancerInternet (0.0.0.0/0)443
Web/app serversLoad balancer security group only8080
DatabaseApp security group only5432
Admin accessBastion or SSM/Bastion service only22 or none

Because each tier references the previous tier's group rather than IP ranges, scaling out adds servers without changing rules.

How Do You Create Rules from the CLI?

# AWS: allow app tier to reach the database tier on 5432
aws ec2 authorize-security-group-ingress --group-id sg-0db0000000000000 \
  --protocol tcp --port 5432 --source-group sg-0app000000000000

# Azure: allow HTTPS from the internet to the web subnet NSG
az network nsg rule create -g rg-prod --nsg-name nsg-web -n allow-https \
  --priority 200 --direction Inbound --access Allow --protocol Tcp \
  --source-address-prefixes Internet --destination-port-ranges 443

# Google Cloud: allow app-tagged VMs to reach db-tagged VMs on 5432
gcloud compute firewall-rules create allow-app-to-db --network prod-vpc \
  --allow tcp:5432 --source-tags app --target-tags db

How Do You Find Risky Rules?

# AWS: security groups with SSH open to the world
aws ec2 describe-security-groups \
  --filters Name=ip-permission.from-port,Values=22 Name=ip-permission.cidr,Values=0.0.0.0/0 \
  --query "SecurityGroups[].{ID:GroupId,Name:GroupName}"

# Google Cloud: rules open to 0.0.0.0/0
gcloud compute firewall-rules list --filter="sourceRanges:0.0.0.0/0" \
  --format="table(name,network,allowed[].map().firewall_rule().list())"

CIS benchmarks for each cloud include checks for unrestricted SSH and RDP. Cloud security posture tools run these continuously.

What Are the Best Practices?

  • Deny by default; open only required ports from required sources.
  • Use managed access such as AWS Systems Manager Session Manager, Azure Bastion or Google IAP instead of open SSH or RDP.
  • Control outbound traffic too, not just inbound.
  • Manage rules as code (Terraform, Bicep) with review.
  • Enable flow logs and review denied traffic.

Related: what a VPC is and types of firewalls. WebAsha offers cloud security training for AWS and Azure.

References

Frequently Asked Questions

An Azure resource containing stateful allow and deny rules that filter traffic to subnets or network interfaces.

Yes. Return traffic for allowed connections is permitted automatically. Network ACLs are stateless.

No. They only contain allow rules. Use network ACLs or AWS Network Firewall for explicit denies.

Small setups may not. Larger ones add a managed firewall for central policy, domain filtering and intrusion prevention.

By network tags or service accounts, and they apply across the VPC network rather than per subnet.

No. Use Session Manager, Azure Bastion or Google IAP, or restrict SSH to a known IP range.

An Azure feature that groups VMs by role so NSG rules can reference the group instead of IP addresses.

Query security groups or firewall rules for 0.0.0.0/0 sources, or use CIS benchmark checks in a posture tool.

What's Your Reaction?

Like Like 0
Dislike Dislike 0
Love Love 0
Funny Funny 0
Wow Wow 0
Sad Sad 0
Angry Angry 0
Vaishnavi

Vaishnavi is a skilled tech professional at the Ethical Hacking Training Institute in Pune, responsible for managing and optimizing the technical infrastructure that supports advanced cybersecurity education. With deep expertise in network security, backend operations, and system performance, she ensures that practical labs, online modules, and assessments run smoothly and securely. Her behind-the-scenes contributions play a vital role in delivering a seamless and secure learning experience for aspiring ethical hackers.