-1

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 192.168.2.19 and my web-server is on 192.168.2.15:6969/test.js. When I redirect the user I can only get him to 192.168.2.15:6969 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 192.168.2.19 -p tcp --dport 80 -j DNAT --to-destination 192.168.2.15:3000/test.js 

1 Answer 1

5

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.

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.