Web Hosting Talk







View Full Version : Port forwarding program?


pmak0
11-27-2002, 02:49 PM
Is there a program that I can run as root, to have it listen on port 80, and forward all incoming TCP connections to another port on the local machine?

There's one catch, though - I want the other program on the local machine to still be able to see the true remote host, rather than 127.0.0.1. Is this possible?

sasha
11-27-2002, 03:09 PM
may I assume that this have something to do with webserver? If so you can setup Apache to listen any where you want ti to with Lister AnyPortIWant.

you can rewrite (mod_rewrite) all incoming connections from 80 to AnyPortIWant. I do not know if you turn rewrite engine on and off based on IP but I assume you can.

There's one catch, though - I want the other program on the local machine to still be able to see the true remote host, rather than 127.0.0.1. Is this possible?
Sorry, lost you there.

pmak0
11-27-2002, 03:14 PM
sasha: No, the service that I wish to forward is not a web server.

> There's one catch, though - I want the other program
> on the local machine to still be able to see the true
> remote host, rather than 127.0.0.1. Is this possible?

If I used a standard port forwarding program that listens for connections on port 80, then opens a connection to a higher port and passes all the data from incoming connections through, then from the point of view of the high port, all the incoming connections are coming from 127.0.0.1. That is bad, because then I can't tell where connections are coming from for security reasons.

Shyne
11-27-2002, 03:40 PM
rinetd worked perfectly for me when forwarding SMTP port 25.

pmak0
11-27-2002, 03:52 PM
> rinetd worked perfectly for me when forwarding SMTP port 25.

Hmm... the documentation of rinetd says "The server redirected to is not able to identify the host the client really came from. This cannot be corrected".

I wonder if what I want to do is actually impossible. Or maybe it's possible but would require kernel hacking (which sounds dangerous)?

pmak0
11-27-2002, 03:57 PM
Does iptables support rewrite rules to rewrite the destination port? Maybe I can do it that way...

MarkIL
11-27-2002, 05:47 PM
Port forwarding With IPTables (http://www.experts-exchange.com/Networking/Linux_Networking/Q_20360913.html)

pmak0
11-27-2002, 06:16 PM
Originally posted by lewney
Port forwarding With IPTables (http://www.experts-exchange.com/Networking/Linux_Networking/Q_20360913.html)

Thanks!!

That was exactly what I needed, and I got it to work.