Communication Networks · Visualized

Firewalls & Packet Filtering

Network Security

Filtering the traffic at the door: firewall rules, stateful inspection and where each type sits.

1 interactive subtopic — each one animated, step-through and explained.

Firewalls & Packet Filtering

Network Security

A firewall sits between your trusted network and the wild internet and decides, packet by packet, what may pass. Packet filters judge each packet in isolation by header fields — source/destination IP, ports, protocol — against an ordered rule list. Stateful firewalls go further: they remember active connections and only allow return traffic for sessions that inside hosts started.

How Firewalls & Packet Filtering Works

  1. Every packet arrives and is compared against the rule list from top to bottom.
  2. Each rule matches on 5 fields: protocol, source IP, source port, destination IP, destination port.
  3. First match wins: the rule says ALLOW or DENY, and the packet is forwarded or dropped.
  4. No match → the default policy applies (best practice: deny by default).
  5. A stateful engine additionally tracks connections: outbound SYN creates an entry; inbound packets must belong to it.

Firewalls & Packet Filtering Worked Example

Try it: Toggle rules on/off and send test packets — watch each one walk the rule list to its verdict.

A web reply from 93.0.0.7:443 matches the state entry (inside host asked) → ALLOW. A random inbound packet to port 3389 matches nothing and hits default-deny → DROP. One blocked port is all that stands between a LAN and random scanners.

93.0.0.7:443tcp → 10.0.0.5:51322packet at the door1. tcp any:any → 10.0.0.5:443 ALLOW2. tcp any:any → any:25 DENY3. any any:any → any:any DENYwalked top → bottom · first match decides
ALLOW DENY / drop stateful session match
Stage 1 / 4
Web reply to our server arrives: tcp 93.0.0.7:443 → 10.0.0.5:51322. The firewall starts at the TOP of the rule list.

Firewalls & Packet Filtering: Key Facts to Remember

Generationspacket filter (L3/L4) → stateful (L4 + memory) → application/NGFW (L7, inspects payloads)
Default posturedefault-deny with explicit allows beats default-allow with blockers
Not enough alonefirewalls filter headers (and some payloads) — they cannot fix insecure apps inside

Recommended resourcesAffiliate links · may earn us a commission

Recommended for learners

Cloud hosting for side projectsShip the portfolio project that gets you hired — free credits for new accounts.Claim credits Pro code editor & AI assistantWrite, debug and explain code faster while you practice the patterns here.Try it free Structured coding coursesVideo courses that pair well with visual practice — pick one language and go deep.Browse courses

See how packets really travel

Networks are built on the structures and algorithms you can watch step by step — queues, trees, and routing algorithms.