My computer has two connections: ppp0 (to internet) and eth0 (as masquerade). I'm also running a proxy on port 8080. I'm using this computer as a router. Is there a quick iptables hack that will redirect port 80 to port 8080 (my local proxy)?

link|improve this question
feedback

1 Answer

Traffic from the local machine or from the attached internal network?

For local: iptables -t nat -A OUTPUT -p tcp --dport 80 -j DNAT --to-destination 127.0.0.1:8080

For network: iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j DNAT --to-destination 127.0.0.1:8080

link|improve this answer
Shouldn't you be using REDIRECT for local traffic not DNAT – topdog Jul 29 '10 at 6:43
That's the command I used, but I'm getting errors from Privoxy saying something about the headers being wrong. I'm going to try REDIRECT. – user49657 Jul 29 '10 at 20:54
It's quite possible that's a more efficient solution. I'm actually not sure I've ever tried redirecting to a service on 127.0.0.1 before (most services I run only listen on a specific public IP and not localhost), and if so it was pre-redirect-target days (2.2 kernel). – Jeremy M Jul 30 '10 at 1:06
feedback

Your Answer

 
or
required, but never shown