I have some iptables rules in a linux gateway (ubuntu server 12.04) and all works good. I configured a transparent squid proxy and works too. I'm using this rule.

$IPT -t nat -A PREROUTING -p tcp --destination-port 80 \
-j REDIRECT --to-ports 3128 

But I must use this server for web development testing and demos, and is rejecting all http requests from internet (eht0). I can access without problems from local network (eth1).

When I comment the rule above. All works again. Why this rule is blocking the http requests from wan network?


Actually, this rule is not blocking http traffic from Wan, but redirects this traffic to your Proxy.

In other words, your actual rule redirects both incoming and outgoing http traffic to your gateway on port 3128.

I would suggest to specify source/destination interfaces :

# Traffic from LAN to Internet is redirected to your Proxy
$IPT -t nat -A PREROUTING -p tcp -i eth1 -o eth0 --destination-port 80 -j REDIRECT --to-ports 3128

# Traffic from Internet is redirected to your gateway on port 80
$IPT -t nat -A PREROUTING -p tcp -i eth0 --destination-port 80 -j REDIRECT --to-ports 80

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.