A firewall is a security system that monitors and controls incoming and outgoing network traffic based on predetermined security rules, acting as a barrier between an internal network and external sources to block unauthorized access while permitting authorized communications.