There are several ways of achieving the home gateway solution and we selected the method of IP masquerading (Network Address Translation). This is the most simplest and optimum solution for a home gateway configuration. You may also do this with specialised kernels as done by Linux Router Project or Socks Gateway proxy project. There are other dedicated hardware solutions for the home gateway setup which come with pre-existing configurations.
The IP Masquerading was done with ipfwadm in Linux 2.0 kernels, with ipchains in Linux 2.2 kernels and with iptables in Linux 2.4 kernels. There are obviously several advantages of using the newer versions due to the quality of support, improved implementations and enhanced configuration options. For example, ipchains introduced the concept of chains where as ipfwadm was based on a linear system, and is definitely much easier to administer. Ipchains also allows you to specify the IP protocol type and you may even replace or negate the rules.
Iptables is a stateful mechanism unlike the ipchains or ipfwadm. This allows you to track connections and permit incoming responses to outgoing requests without creating holes in the firewall. The connection tracking opens a specific, temporary hole for responses and only from the contacted server.
In this article, I will discuss only about ipchains and iptables. And I will try to explain all the tips & tricks for doing everything on your own.