What is a Firewall?
In construction, a firewall is a wall in a building that prevents a fire from spreading to other parts of a building. These are super important and help protect people when a building is on fire so they can escape before the whole building burns up.
In the cyber world, a firewall has a similar function to protect you from the dangerous "fires" around the internet or in your local cafe. So what is it, and what does it actually do?
All firewalls basically work to prevent unauthorized connections with your computer or your network and they allow authorized connections through. It might be helpful to think of what would happen without a firewall. If you had no firewall, anyone on your network could access files on your computer or attempt to do other things. On a network level, if you didn't have a firewall people could see your devices and potentially get into your network from the outside.
There are over 65,535 ports* that could potentially allow access to your computer and network, and it's your firewall's job to make sure only the right ports are open and the right ones are closed.
It's a rough world out there with a lot of bad folks who wouldn't mind taking advantage of your computer to do bad things.
Types of Firewalls: Hardware and Software
There are basically two main types of firewalls. There are hardware firewalls that sit on the edge of your network (like where the internet comes in) and they filter internet traffic. There are also software firewalls that run on your phone, computer, or (sometimes) smart devices.
Software firewalls are usually built in to whatever computer you're using, and it's best to just leave them on or make sure that they are on.
Hardware firewalls sometimes require custom configuration to work correctly, but for most homes and small offices, the default "on" should work.
When you should turn off your firewall?
Just about never. I'm racking my brain for when the average person should turn off their firewall (either on their network or on their computer), and I just can't bring them to mind. If you are on a trusted network, you can enable sharing of some files and resources, but you should never completely turn off your firewall.
*There are 65,535 TCP ports, and another 65,535 UDP ports, but who's counting. Here's a good article explaining ports and the differences: https://www.bleepingcomputer.com/tutorials/tcp-and-udp-ports-explained/