What is a Firewall ?
Firewall stands between your network and the internet. It protects your network from outside attacks by hackers. Obviously, this needs to be installed on the computer which is the gateway of your LAN to the internet or some instrument that connects to the internet. Even if you are having a small network at home, having a firewall is recommended since small networks also face some security issues.
How is it done, anyway ?
On Linux, you as an administrator of your network, you can set rules regarding what to do with packets originating from different sources or going to various ports. These rules are instructions to the kernel of the gateway computer. These can be set with the command 'iptables' or 'ipchains' (old way). Most linux distributions come with support for iptables. If iptables is not supported, you need to recompile the kernel with iptables.
You need to be root (administrator) to use iptables. For more information on the command, do 'man iptables'. If you set-up the rules on command-line, they will be lost on next reboot of machine because they are not saved anywhere. Save your rules in a file (a shell script). This shell script is your firewall-script. If you execute this every-time your gateway boots up, the firewall will be set-up. Think of calling this script from your /etc/rc.d/rc.local (on Redhat linux distribution).
