Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

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

I'm trying to redirect all port 80 requests on a single LAN IP to an external squid proxy server outside of my network. For debugging purposes, I'm attempting this from the router level as the application does not have proxy support but does send its requests through port 80.

So far, I've tried plugging this in at the 'run command' box on DDWRT:


iptables -t nat -A PREROUTING --dst $YourIP -p tcp --dport $YourPort -j DNAT --to-destination $TargetIP:$TargetPort
iptables -t nat -A POSTROUTING -p tcp --dst $TargetIP --dport $TargetPort -j SNAT --to-source $YourIP
iptables -t nat -A OUTPUT --dst $YourIP -p tcp --dport $YourPort -j DNAT --to-destination $TargetIP:$TargetPort

It doesn't seem to do anything, though. Requests are still served through my home internet connection from the specified device. Am I going about this the wrong way? Any help is appreciated. When I run "iptables -t nat -L" I see the following:

DNAT       tcp  --  anywhere          tcp dpt:www to:x.x.x.x:23128 
share|improve this question

migrated from Feb 29 '12 at 1:41

This question came from our site for system and network administrators.

What is YourIP= in your context? Is that the IP address assigned to the client you are testing from? It is the dd-wrt box going to be making http requests? If not you can drop the -A OUTPUT rule. You also, probably don't need the SNAT. – Zoredache Feb 17 '12 at 0:47
"requests are still served through my home internet connection"... home networking questions are not appropriate for ServerFault. Please read our FAQ. – kce Feb 29 '12 at 1:41

You must log in to answer this question.

Browse other questions tagged .