A network firewall is a security system that monitors and controls incoming and outgoing network traffic based on predefined security rules. A firewall can be hardware or software and serves as a barrier between a trusted internal network and unauthenticated external networks such as the Internet. Its main function is to protect the network by preventing unwanted network attacks and restricting access to sensitive data.