← Back to Library
SecurityBeginner11 min readJul 19, 2026By Tech-ikigai Instructors
🧱 The internet's bouncer

How do firewalls inspect packets?

Every packet that tries to enter or leave a network has to pass a checkpoint first. Meet Packet-y — a little envelope of data — as it goes through three increasingly strict security guards on its way into an office building.

📽️ Comic Strip: Packet-y's Day at the Checkpoint

The whole story in six panels, before we break it down level by level.

1
📨🚶
"Delivering data to Office Server, room 443!"
2
📨🪪👮
stamp!
Guard 1: "Show your address label and door number."
3
📨📒👮
Guard 2: "Are you replying to someone who just left? Let me check my logbook."
4
📨🔦👮
scan...
Guard 3: "New visitor! I need to open the box and actually look inside."
5
📨🦠🚫
BEEP!
"Wait — this box smells like a virus. Blocked!"
6
📨✅🏢
"All clear! Delivered safely."

🧱 So what actually is a firewall?

Not a wall of fire — a security checkpoint that every packet must pass through.

  • A firewall sits between two networks and decides, packet by packet: let it through, or block it?
  • Some firewalls just glance at the envelope, others actually open the box — that's what "levels of inspection" means.
  • Every decision follows a default policy: "block everything unless explicitly allowed" (default-deny, safer) or "allow everything unless explicitly blocked" (default-allow, riskier).
🔎 Try it yourself
sudo ufw status verbose (Ubuntu/Debian) sudo firewall-cmd --state (RHEL/CentOS) netsh advfirewall show allprofiles (Windows)

Each of these tells you the current default policy — deny or allow — for your own machine's firewall.

🏠 Where does a firewall actually live?

Not one guard — often several, stationed at different gates.

  • Network firewall — sits at the front gate of a whole network (built into a router, or a dedicated appliance). Protects everyone behind it at once.
  • Host firewall — runs on each individual device (Windows Defender Firewall, macOS firewall, Linux ufw/firewalld). Useful "defense in depth."
  • In the cloud, this splits into Security Groups (instance-level) and Network ACLs (subnet-level) — the same two-layer idea, renamed.

📦 Quick recap: what's inside a packet?

Different firewall levels read different layers of the same envelope.

IP header — Src IP, Dst IP TCP/UDP header — Src Port, Dst Port, flags (SYN/ACK) Payload / actual content GET /download.exe HTTP/1.1 ← Only deep inspection reads this far in!
Read by Level 1 Also read by Level 2 Only read by Level 3
1
Packet Filtering — stateless

Guard 1: "Show me your labels"

🪪 The first guard doesn't care who you talked to five minutes ago. Every parcel is checked fresh against a printed list.
  • Reads only outer headers: source IP, destination IP, source port, destination port, protocol.
  • Compares them against a static list of rules called an Access Control List (ACL).
  • Has no memory — each packet is judged on its own.
  • Fast, but easy to fool with a crafted header.
🔎 Try it yourself
sudo iptables -L -n -v sudo firewall-cmd --list-all (RHEL/CentOS) netsh advfirewall firewall show rule name=all (Windows)
2
Stateful Inspection

Guard 2: "Didn't I just see you leave?"

📒 The second guard keeps a logbook. If you stepped out five minutes ago, they wave you back in without a full re-check.
  • Still reads headers, but also tracks ongoing connections in a state table.
  • If your computer opened a connection out, the matching reply is automatically allowed back in.
  • An unsolicited "reply" to a conversation that never started is dropped.
  • This is what most home routers and office firewalls actually run.
🔎 Try it yourself
sudo conntrack -L netstat -ano | findstr ESTABLISHED (Windows) Wireshark filter: tcp.flags.syn==1 && tcp.flags.ack==0
3
Deep Packet Inspection (DPI)

Guard 3: "I'm actually opening the box"

🔦 The third guard doesn't just trust the label. They open the parcel and check what's really inside.
  • Reads all the way to the payload / application layer.
  • Can block a specific URL, file type, or keyword — even if the port looks normal.
  • Compares content against known malware signatures.
  • More thorough, but slower.
🔎 Try it yourself
sudo tcpdump -A port 80 | grep "Host:" Wireshark filter: http.request or tls.handshake.extensions_server_name

Note: this only works on unencrypted traffic; for HTTPS, a real DPI firewall must first decrypt it.

🚨 Attacks a firewall helps block

Real threats, and which guard catches each one.

🔎 Port scanning

An attacker knocks on every port. Even Level 1 helps — closed ports drop probes so the attacker learns nothing.

🌊 SYN flood (DoS)

Thousands of half-open handshakes. Stateful firewalls (Level 2) cap or drop excess before the server drowns.

🎭 IP spoofing

Faked "from" address. Firewalls verify the packet arrived on the correct interface ("reverse path filtering").

🦠 Malware delivery

Bad content hidden in normal-looking traffic. Only Level 3 (DPI) actually reads the content and catches it.

🎓 Level Up: Next-Gen Firewalls

Modern firewalls combine every guard above, plus superpowers.

🕵️ Intrusion Prevention (IPS)

Watches for attack patterns across many packets, like someone jiggling the same door 500 times.

👤 User & app awareness

"Amit can use video calls, but not file-sharing apps" — identifies the app and user, not just the port.

🔓 TLS/SSL inspection

Decrypts HTTPS at the checkpoint, inspects it, then re-encrypts it — like a guard with special see-through glasses.

🌐 Live threat intelligence

Constantly-updated blocklists — a signature spotted an hour ago is already blocked at your gate today.

🏝️ DMZ — the visitor lobby

Public servers sit in a separate zone — reachable from the internet, firewalled off from internal systems.

🔄 NAT — one address, many devices

Many internal devices share one public IP; NAT rewrites addresses as packets cross the firewall.

🧩 The three levels, side by side

LevelOSI layer readRemembers past packets?Sees actual content?Speed
Packet FilterNetwork / Transport (3-4)NoNo⚡ Fastest
StatefulNetwork / Transport (3-4)Yes — state tableNo⚡ Fast
Deep Packet InspectionApplication (7)YesYes🐢 Slower, more thorough

The whole checkpoint, at a glance

🏠Network firewall vs host firewall
1Level 1: check headers vs a static list
2Level 2: check the connection state table
3Level 3: open the box, inspect the content
+Next-gen: IPS, app-aware, TLS, DMZ, NAT
🚨Blocks port scans, SYN floods, spoofing, malware
Made with 🧱 for curious kids (and grown-ups) learning how the internet's guards work.
Share

Comments (0)

0/800
  • Be the first to comment.