I'm trying to redirect a host to a specific link on my network when they try to browse through HTTP.

The IP address of the host I'm trying to redirect is and my web-server is on When I redirect the user I can only get him to and not the relative path. I tried specifying in the iptables command but it did not work.

Here's what I did:

echo 1 > /proc/sys/net/ipv4/ip_forward 
iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 3000
iptables -t nat -A POSTROUTING -j MASQUERADE 
iptables -t nat -A PREROUTING -s -p tcp --dport 80 -j DNAT 

You cannot do this with iptables. You're trying to perform an HTTP redirect, so you'll need to perform the redirect using an application that speaks HTTP, like apache or nginx.


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.