A firewall is a network security system, either hardware- or software-based, that uses rules to control incoming and outgoing network traffic.