Definition
A firewall is a security layer that decides which network connections are allowed in and out. It can be hardware in a router or software built into your computer. Its rules often allow outgoing web traffic and block unexpected incoming connections.
Most home routers include a basic firewall that blocks unsolicited incoming traffic. Operating systems also ship with a host firewall, which can be turned on in the security settings.
A firewall does not protect against threats you invite in, such as a malicious file you open yourself, so it works best alongside updates, strong passwords and careful downloads.