A firewall is a device that enforces network security policy. Next-generation firewalls are capable of detecting and blocking sophisticated attacks by applying security rules at the application level, as well as at the port or communication protocol level.