I want to be able to redirect a host in my Lan to an specific ip address and port. I can achieve one thing which is that only my desired host can access the ip address, but I can't get the user to redirect when they type something in their url bar. I will show you the steps I've taken to accomplish this

echo "1" > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A PREROUTING -p tcp --dport 5000 -j DNAT --to-destination
iptables -t nat -A POSTROUTING -j MASQUERADE

#The address below is the host I'm redirecting 
iptables -t nat -A PREROUTING -s -p tcp --dport 5000 -j DNAT --to-destination

Please let me know how can I accomplish this.

1 Answer 1


Can you try this setup:

iptables -t nat -A INPUT -p tcp --dport 5000 -j DNAT --to-destination
iptables -t nat -A SRCNAT -j MASQUERADE

You can see more examples here. It should work, but why are you trying implement at firewall level anyway?

If you have a webserver at your host why don't you just add redirect to the right address at your .htaccess, for example? It will be the easiest and robust way to do, I can highly recommend it instead.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .