u need to learn "iptables"
u may also use "squid" cache proxy with "iptables". its called transparent proxy
u may find documents at www.netfilter.org
i will try to explain basicly how to share internet connection for your local network, but these will just share internet connection via NAT, visit www.netfilter.org
to configure your firewall.
first enable routing beetween network devices.
edit "/etc/sysctl.conf" file and chance the following line
net.ipv4.ip_forward = 1
the following command enables NAT for local network (chance 192.168.0.0/24 to your real local network) eth0 must have a static public ip
iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -o eth0 -j SNAT --to ip_of_eth0
and save iptables config:
service iptables save