Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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)?

share|improve this question

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

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

share|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 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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.