Firewalls monitor and filter network traffic based on security policies. There are different types of firewalls that use various methods like packet filtering, application-level gateways, stateful inspection, and more. Firewalls are necessary to protect networks from threats and work by allowing approved traffic while blocking dangerous traffic according to pre-set policies. They defend networks by detecting and responding to malware and other attacks across the entire system.