Answer

A firewall is a network security device (hardware or software) that monitors and controls incoming and outgoing network traffic based on predefined security rules. It acts as a barrier between a trusted internal network and untrusted external networks. Types: Packet-filtering firewall: inspects packets at the network layer (IP/port rules). Stateful inspection firewall: tracks the state of connections, allowing return traffic for established connections. Application-layer firewall (WAF): inspects HTTP traffic, understands application protocols. Next-generation firewall (NGFW): combines stateful inspection with DPI (Deep Packet Inspection), IDS/IPS, and application awareness. Rules are typically defined as: source IP, destination IP, port, protocol, and action (allow/deny/log).