## TL;DR
A firewall is a network security system that monitors and controls incoming/outgoing traffic based on predetermined rules. Types: packet filtering (stateless, layer 3/4), stateful inspection (tracks connection state), application-layer (WAF, layer 7), next-generation (NGFW, combines all).
## Core Explanation
Packet filters examine source/destination IP, port, protocol. Stateful firewalls maintain connection tables and can make contextual decisions (allow reply packets for established connections). WAF (Web Application Firewall) inspects HTTP requests for SQL injection, XSS, and other application attacks. Modern cloud-native approaches: security groups (AWS), network policies (Kubernetes).
## Further Reading
- [undefined](undefined)