← Blog / Systems

NSGs vs a Firewall Appliance: Which Layer Does What

A common question in Azure designs: if we have network security groups, why do we need a firewall? And if we have a firewall, why bother with NSGs? The short answer is that they work at different layers and are good at different things. Use both, on purpose.

What an NSG is

A network security group is a stateful packet filter attached to a subnet or a network interface. A rule matches on source, destination, port and protocol, and either allows or denies. That is all it does — and it does it very well, for free, right next to the workload.

What it cannot do: look inside the traffic, filter by URL or application, perform NAT, terminate a VPN, or give you one consolidated log of everything crossing your network.

What a firewall adds

A firewall appliance — a FortiGate network virtual appliance, or Azure Firewall — sits in the path and makes decisions with more context:

  • Application and URL awareness, not just ports.
  • Intrusion prevention and threat intelligence.
  • Source and destination NAT for inbound and outbound flows.
  • IPsec and SSL VPN termination.
  • Central logging: one place to answer “what talked to what?”

The cost is that traffic only gets this treatment if routing actually sends it through the firewall.

A sensible split

Firewall for boundaries. Anything crossing between trust zones — internet to workload, on-premises to cloud, one environment to another — goes through the firewall, where policy is written once and logged centrally.

NSGs for the inside. Within a workload, NSGs enforce micro-segmentation: the web tier may reach the app tier on one port, the app tier may reach the database on one port, and nothing else is allowed. Application security groups let you write those rules by role instead of by IP address.

Defence in depth, not duplication

Do not copy the whole firewall rulebase into NSGs. Keep NSG rules coarse and stable: deny by default, allow the few flows the workload needs, and always permit the Azure load balancer probe. If a route table is ever changed by mistake and traffic slips around the firewall, the NSG is the layer that still says no.

One practical habit

Turn on flow logs for your NSGs and send firewall logs to the same workspace. When something is blocked, the first question is always “which layer dropped it?” — and you want that answer in one query, not two consoles.

Next: Hub-and-Spoke in Azure: Where the Firewall Actually Goes →