🛡️ Firewalls: Types & Functions

📌 Overview

A Firewall is a network security device (hardware or software) that monitors and controls incoming and outgoing network traffic based on predetermined security rules.

Think of it as the Security Guard of your network. It decides who gets in and who stays out.


🚦 Types of Firewalls

1. Packet Filtering Firewall (The Basic Guard)

This is the oldest and simplest type. It inspects packets individually based on headers (Source IP, Destination IP, Port, Protocol).

Analogy: A security guard who only checks your ID card but doesn't check if you are carrying a weapon or if you were invited.

2. Stateful Inspection Firewall (The Smart Guard)

This is a modern evolution of packet filtering. It keeps track of the State of active connections (i.e., it remembers if a packet is part of an existing conversation).

Analogy: A receptionist who knows you went out for lunch, so when you come back, they let you in without checking ID again.

3. Proxy Service / Application Gateway (The Middleman)

This firewall acts as an intermediary between the internal user and the external web. The user connects to the Proxy, and the Proxy connects to the Internet.

Analogy: You give your shopping list to a helper. The helper goes to the shop, buys items, checks them for quality, and then brings them to you. You never talk to the shop directly.


📊 Comparison Table

FeaturePacket Filtering 📨Stateful Inspection 🧠Proxy / App Gateway 🕵️
OSI LayerLayer 3 / 4Layer 3 / 4Layer 7
Speed🚀 Fastest⚡ Moderate🐢 Slowest
Security🔓 Low🔒 Medium🔐 High
Memory UsageSub-ZeroHigh (holds state)High
Azure EquivNSGAzure FirewallApp Gateway / WAF

☁️ Azure Context

  1. Network Security Group (NSG): This is a Packet Filtering firewall. It allows/denies based on 5-tuple (Src IP, Dst IP, Protocol, Src Port, Dst Port). It is Stateless? Actually, Azure NSG is technically stateful (if you allow inbound, outbound is auto-allowed), but usually categorized as basic filtering.
  2. Azure Firewall: A managed, cloud-native firewall that offers Stateful Inspection and threat intelligence.
  3. Application Gateway (WAF): Operates at Layer 7 (Proxy). Used for Web Applications to protect against SQL Injection, XSS.

💡 Hinglish Explanation

1. Packet Filtering (Basic Chowkidar)

2. Stateful Inspection (Yaadaash wala Chowkidar)

3. Proxy Service (Dalaal / Middleman)


⚡ Exam Tips

  1. Stateless vs Stateful: Packet filtering is often called stateless (though strictly speaking some implementations differ). Stateful remembers the session.
  2. Latency: Proxy is safest but adds most latency. Packet filtering is fastest.
  3. Layers: Know which firewall sits on which OSI layer (L3/L4 vs L7).