A firewall is a network security device that prevents unauthorised access to a network. It inspects incoming and outgoing traffic using a set of security rules to identify and block threats.