I am developing firewall on iptables on kernal 2.4. I am reffering following site for doing masquerading in iptables.
http://muse.linuxmafia.org/netfilter
 
 
 
Rgds
Girish