The use of linux packet filtering features is mature and well-documented in many places throughout the Internet. One of the most thorough introductions to the use of iptables has been collected by Oskar Andreasson at his Iptables tutorial. For further reference material on the use of iptables consult this resource.
For those continuing to use ipchains the ipchains HOWTO courtesy of TLDP provides an introduction to the world of ipchains.
For kernel 2.4, understanding the sequence of packet mangling, filtering and network address translation is key. The kernel packet traveling diagram provides a visual representation of the path a packet takes through the kernel. Here you will see the netfilter hooks, traffic control, and routing stages. A similar picture of kernel 2.4's packet path is available in a single page PDF entitled Linux Kernel 2.4 Packet handling.
See also Section I.1.8, “ipchains Resources” and Section I.1.7, “Netfilter Resources” in the appendices for a more complete set of references and links.