Firewall provides security for networks by controlling access between internal and external networks. There are different types of firewalls including packet filters, application-level gateways, and circuit-level gateways. A packet filter firewall applies rules to IP packets to determine whether to forward or discard them based on information like source/destination addresses and ports. An application-level gateway provides additional security over a packet filter by requiring traffic to go through a proxy for each application/protocol. A network-based firewall protects all computers on an internal network, while a host-based firewall protects only an individual computer.