4.3.29 · D3 · HinglishComputer Networks

Worked examplesFirewalls — stateless vs stateful packet filtering

3,617 words16 min read↑ Read in English

4.3.29 · D3 · Coding › Computer Networks › Firewalls — stateless vs stateful packet filtering

Shuru karne se pehle, teen simple-bhasha reminders (koi bhi term isse pehle use nahi karenge):

Hum poori jagah parent ka chhota sa ruleset reuse karte hain:

# Dir Proto Src Dst Dst Port Flag Action
1 out TCP 10.0.0.0/24 any 80,443 ALLOW
2 in TCP any 10.0.0.0/24 >1023 ACK=1 ALLOW
3 * * any any any DENY

Hamara internal network hai 10.0.0.0/24 (addresses 10.0.0.010.0.0.255).


Scenario matrix

Ek filter jo bhi packet dekhta hai woh in cells mein se kisi ek mein aata hai. Do axes jo matter karte hain woh hain direction (out / in) aur flags + state kya kehte hain. Hum degenerate inputs (empty table, port on boundary) aur limiting behaviour (table full) bhi fold in karte hain.

Cell Direction Flag pattern Legit? Stateless verdict Stateful verdict Covered by
A out SYN (ACK=0) new conn ALLOW (rule 1) ALLOW + create entry Ex 1
B in SYN-ACK, asli reply hai ALLOW (rule 2, ACK=1) ALLOW via table Ex 2
C in ACK=1, koi asli conn nahi (spoof) ALLOW (leak!) DROP (not in table) Ex 3
D in SYN (ACK=0), naya inbound conn DROP (rule 2 needs ACK=1) DROP Ex 4
E in dst port = 1023 vs 1024 (boundary) rule 2 edge test same Ex 5
F in ESTABLISHED conn par data ALLOW (ACK=1) ALLOW (fast path) Ex 6
G close FIN vs RST tears down ALLOW (if ACK=1) ALLOW + delete entry Ex 7
H in SYN flood, table full (limiting) shrugs (no table) table exhaustion DoS Ex 8
I in active-FTP 2nd channel (word problem) needs huge port hole ALG opens 1 port Ex 9
J in UDP DNS reply (no flags!) (exam twist) rule 2 fails (no ACK) ALLOW via pseudo-state Ex 10

Ab hum har cell ke liye ek example kaam karte hain. Directions aur states figures mein draw hain — words se zyada arrows dekho.

Figure — Firewalls — stateless vs stateful packet filtering

Worked examples


Recall Cover check — har cell ke liye ek line

Cell C: forged ACK=1 packet par stateless ka verdict? ::: ALLOW (the leak) — stateful DROP karta hai. Cell E: kya dst port 1023 rule 2 ka >1023 test pass karta hai? ::: Nahi — strictly greater, toh DENY. Cell G: RST teardown FIN se kaise alag hota hai? ::: RST turant band karta hai (koi handshake nahi, ACK=0 ho sakta hai); FIN negotiated close hai. Cell H: SYN flood kaun sa firewall exhaust karta hai? ::: Stateful wala (uski table bhar jaati hai); stateless shrug karta hai. Cell J: rule 2 UDP DNS reply ke liye kyun fail karta hai? ::: UDP mein ACK flag nahi hota (aur woh TCP bhi nahi hai), toh ACK trick match nahi kar sakti.