A firewall is used to protect a networked server from damage by those who log in to it. This can either be a computer equipped with security features, software protection (called defensive coding), or both. A firewall allows only certain messages from the Internet to flow in and out of the internal network. So, basically, it's a lot like a wall of fire. Whatever.
http://www.firewall-net.com/en/
http://www.linux-firewall-tools.com/linux/
http://www.tldp.org/HOWTO/Firewall-HOWTO.html
Note: What many homeusers call a FireWall is actually just an IDS (IntrusionDetectionSystem) or a so called PersonalFirewall.
Like for example the popular WindoWs tools ZoneAlarm and BlackIceDefender A real firewall is a piece of hardware independent of the system that is to be protected.
For Linux you should look into IpTables.