A firewall is software or hardware that checks information coming from the Internet or a network, and then either blocks it or allows it to pass through to your computer, depending on your firewall settings.

A firewall can help prevent hackers or malicious software (such as worms) from gaining access to your computer through a network or the Internet. A firewall can also help stop your computer from sending malicious software to other computers.

The following illustration shows how a firewall works.

Illustration showing how a firewall creates a barrier between the Internet and your computer
Just as a brick wall can create a physical barrier, a firewall creates a barrier between the Internet and your computer

A firewall isn't the same thing as an antivirus program. To help protect your computer, you need both a firewall and an antivirus and anti-malware program.