I'm trying to force one PC to use a remote transparent squid proxy by re-routing all outgoing packets headed for port 80 to the squid proxy, although I'm having some difficulty with the exact iptables command line.
The mini-HOWTO at http://tldp.org/HOWTO/TransparentProxy-6.html has some good links for the two "extreme" cases: a three (or more) machine setup which has a client, router, and proxy, and a single machine setup where all three on the same machine.
In my setup, I have a machine (called foo), with an IP of 192.168.1.100. Normally, it connects to the internet through a router at 192.168.1.1, which does NAT and has a public IP. In this case, foo also is connected via an OpenVPN tunnel (foo's tunnel address is 10.8.0.5/6) to a machine called bar (remote address 10.8.0.1), which runs squid. I want to use iptables to route all outgoing packets from foo headed for port 80 to bar's squid proxy, on port 3128.
I haven't been able to figure out which chain and which targets to use; all my attempts have either been illegal (-A OUTPUT without -t nat and --to-destination) or just not done any good (various combinations of -A PREROUTING, OUTPUT, POSTROUTING, etc).
EDIT: The closest I think I got was this:
iptables -t nat -A OUTPUT -p tcp --dport 80 -j DNAT --to 10.8.0.1:3128
Now, no port 80 traffic gets anywhere, but at least it's getting processed. Using -A PREROUTING fails... maybe because the packets originate locally instead of being routed through the machine?