A firewall is a software or hardware program that protects computers and networks from viruses, worms, and hackers by blocking unauthorized access and data while allowing permitted communications. While firewalls can prevent viruses and attacks from the internet, they cannot stop email viruses or phishing scams that come through email. There are two main types of firewalls - software firewalls like antivirus programs and hardware firewalls that are routers with built-in firewall capabilities to protect entire home networks.