You'll probably be using IP-MASQ to do this, so check out the IP Masquerading HOWTO:
For ipchains:
http://netfilter.samba.org/ipchains/HOWTO-3.html#ss3.1
For iptables:...