Dansguardian/Squid machine as network gateway - how I do setup IP Tables?

I've got an Ubuntu box, server 7.10, single NIC setup and running Dans Gaurdian and Squid.  I've got the box working as a proxy server.  Here is the only IP Tables rule in there right now:

sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -i eth0  -j DNAT --to

That works great for proxy only, but what I would like to do is make this machine the gateway for the whole network, and just send all non 80 outbound traffic to the actually gateway at  I have a whole list of rules I've tried that don't work, for example (assume for all these broekn examples, that the above rule is still applied):

sudo iptables -t nat -A PREROUTING -i eth0 --protocol tcp -j DNAT --to-destination
sudo iptables -t nat -A PREROUTING -i eth0 --protocol udp -j DNAT --to-destination

or this:

sudo iptables -t nat -A PREROUTING -i eth0 -j DNAT --to-destination

or this (before I remembered that IPTables works in a linear fashion, once it matches a rule it stops processing):

sudo iptables -t nat -A FORWARD -p udp --dport 1:79 -i eth0 -j DNAT --to-destination
sudo iptables -t nat -A FORWARD -p udp --dport 80:65535 -i eth0 -j DNAT --to-destination
sudo iptables -t nat -A FORWARD -p tcp --dport 1:79 -i eth0 -j DNAT --to-destination
sudo iptables -t nat -A FORWARD -p tcp --dport 81:65535 -i eth0 -j DNAT --to-destination

None of that worked.  I've tried everything I can think of, but I'm just not getting something right.  when I try to use the DG box as the gateway on my local machine, the internet works, but all other outbound traffic is stopped by the DG box.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

http:// thevpn.guruCommented:
Try this

route add default gw   dev eth0

iiptables -t nat -A POSTROUTING -o eth0 -j SNAT --to-source ip.of.dansguardian.box
echo "Enabling IP forwarding"
echo 1 > /proc/sys/net/ipv4/ip_forward

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
pbenningfieldAuthor Commented:
Thanks for the reply!  I got tied up a bit, but I'm back in the game again and I'll be able to test things more rapidly now.  

The default GW is already set to (double checked!)

Typing in the iptables -t nat -A POSTROUTING -o eth0....etc command produces no output whatsoever, the ssh session just locks up and the box has to be rebooted.  

The first echo command just echos "Enabling IP Forwarding" in the screen

The second echo command give me this output:
sudo echo 1 > /proc/sys/net/ipv4/ip_forwarding                  
-bash: /proc/sys/net/ipv4/ip_forwarding: No such file or directory

I tried it without the sudo also, and it gave the same output.
pbenningfieldAuthor Commented:
I've also done this:
sudo pico /etc/sysctl.conf
where I editted the line:
#net.ipv4.conf.default.forwarding=1 (I removed the comment #)

I also had to change the line in the syscrt.conf file to read "net.ipv4.ip_forward=1

after a reboot, I re-applied the following 2 iptable rules:
sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -i eth0  -j DNAT --to
sudo iptables -t nat -A POSTROUTING -o eth0 -j SNAT --to

and it started working just like it should!  I could not have done this without your help, so I'm closing this question and awarding you the points.  

Thanks again!!!
pbenningfieldAuthor Commented:
Thanks again!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux Distributions

From novice to tech pro — start learning today.