Firewalls act as a barrier between an internal network and external networks like the internet to enforce security policies and control access. They work by filtering traffic passing through them based on criteria like source/destination addresses and ports, and can block unauthorized access while allowing permitted services. The document discusses the need for firewalls, how they function, common types like filter-based, proxy-based and stateful inspection firewalls, and what threats they help protect against while also noting some limitations.