Well, in your car it’s the "wall" of metal behind the dashboard between you and the engine that prevents engine fires from roasting you and your passengers.
A firewall for your computer is much the same - it’s to keep you from getting burned.
A firewall’s purpose is very simple: to block, or filter, certain types of network traffic from reaching your computer. What do I mean by "certain types"? There are things you want to get, like the pages of web sites you visit, or the software you might download. And then there are other things you might not want, like people accessing your computer remotely, or viruses and worms infecting your machine.
It controls and allows you to decide which applications can and cannot use the Internet.
Some firewalls will also monitor outgoing traffic for suspicious behavior. One characteristic of many viruses is that once you’re infected they attempt to establish connections to other computer to spread. Many software firewalls will detect, and either warn you or simply prevent it.
And that leads to a very important distinction in firewalls - there are two types: hardware and software.
A hardware firewall is just that - a box that sits between you and the internet that performs the filtering function. Traffic that is filtered out never reaches your computer. Broadband routers perform the function of a firewall quite nicely, and are typically what we recommend.
A software firewall is a program that runs on your computer and at the very lowest level, monitors your network traffic. The firewall prevents filtered traffic from getting through to the operating system.
The good news is that if you’re running Windows XP, you already have a firewall built-in. It’s a simple matter of turning it on to get the protection you’re looking for.
If you decide to go with a hardware firewall we recommend Linksys or if your the adventurous type and have an old PC collecting dust you can build your own firewall
Software firewalls are just as effective as and cheaper than their hardware counterparts. We highly recommend Zone Alarm from Zone Labs. Zone Alarm makes configuring a firewall, which sounds like a daunting task to the majority of computer users, incredibly easy with a wizard. Best of all it’s 100% free!
Link: How Firewalls Work, Internet Firewalls: FAQ