Rerouting traffic from port 80 to another port on a single ip

Posted by zam on Super User See other posts from Super User or by zam
Published on 2012-07-01T03:04:15Z Indexed on 2012/07/01 3:17 UTC
Read the original article Hit count: 416

Filed under:

I have a server with multiple IP addresses associated with it. I'm trying to run a node.js web server (which I do not want to run as root), using only one of those ip addresses (it would be very bad if the traffic from all the ip addresses were forwarded).

Through searching superuser, it looked like this could be possible with iptables:

How to setting up iptables for traffic fowarding on port 80 from specific sources

iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 --source 212.333.111.222 -j REDIRECT --to-port 9020

However, I do not understand why eth0 is needed.

According to:

this could be done with:

iptables -t nat -A PREROUTING -p tcp --dport 2525 -j REDIRECT --to-ports 25

What is the correct way of forwarding traffic from a single ip on port 80, lets say to another port on the same server, lets say

thanks for your help!

© Super User or respective owner

Related posts about port-forwarding

Related posts about iptables