A firewall protects the server from unauthorized access by closing off unused ports and controlling access to your server.
There are two main types of firewalls: hardware and software.
A software firewall runs on the server itself. Examples of software firewalls are Windows Firewall, ZoneAlarm and IPtables. Software firewalls are a cost effective way to protect low-traffic, single server deployments.
A hardware runs separate from the server andadds an extra layer of security and performance by offloading the firewall task to a dedicated device. Hardware firewalls are extremely beneficial in multiple-server deployments or heavy traffic conditions.