LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   IPtables Forward 1 Port to another on the same IP (https://www.linuxquestions.org/questions/linux-networking-3/iptables-forward-1-port-to-another-on-the-same-ip-277439/)

KevinB 01-13-2005 03:13 PM

IPtables Forward 1 Port to another on the same IP
 
I'm 95% sure this can be done with IP tables.

I'd like to forward all requests at port 80 to a server that's actually listening at port 5580. How could I do this?

Thanks,
Kevin

Demonbane 01-13-2005 10:17 PM

If its on the same server:
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-ports 5580

otherwise:
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j DNAT --to <server>:5580

If there are http requests which come from the same LAN as the server than you need to do SNAT in addition to DNAT.

KevinB 01-13-2005 10:56 PM

Thanks for your help. I should have clarified that it was on the same server.


All times are GMT -5. The time now is 04:12 AM.