There are a few things which are typically referred to as "firewalls", with different purposes. All of them however control access to a network by restricting which ports and IP addresses can be connected to.
## Software Firewalls
This is the thing built into Windows and other operating systems that pops up boxes saying "Do you want to allow [thing x] to connect to the Internet?". They're designed to prevent malicious software that has been installed on your machine sending your data to other places, or bulk mailing people. They can also be used to restrict connections coming in to your computer.
## Hardware Firewalls