LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   IP tables -- re route a port (https://www.linuxquestions.org/questions/linux-newbie-8/ip-tables-re-route-a-port-452305/)

Dan8080 06-07-2006 12:47 AM

IP tables -- re route a port
 
Hi,

I'm looking to re-route connections coming into port 80, to actually go to 81. What I do now is:

I have two apaches. One setup on 80, one on 81. The 80 one contains a mod_rewrite condition that accepts the request, then rides the person onto the 81.

RewriteEngine On
RewriteRule (.*) h_t_t_p://%{HTTP_HOST}:81/$1

That's my code. Works fine, but... someone said I could use this instead:

iptables -t nat A PREROUTING -p tcp --dport 80 -j DNAT --to-destination webserver-ip-address:81

This is the code I was given. However, it doesn't work when I enter it. I just get "Bad arguement 'A'" when I put it in the termial. Also for destination web server IP address, what do I put, my router IP or the actual IP, and what does this do exactly?

Thanks for your time,
Dan

dimsh 06-07-2006 02:17 AM

Hi

you have replaced "-A" with "A" only, (without dash).

I use this to forward ports as following:
Code:

iptables -t nat -A PREROUTING -d 1.2.3.4 -p tcp --dport 80 -j DNAT --to-destination 1.2.3.4:81
where 1.2.3.4 is my server IP address.
and it is working.

just a reminder: ports 80 and 81 must be allowed in your INPUT chain.
hope this help

Dan8080 06-07-2006 11:43 PM

Hi,

Thanks, but for some reason it does not work, or I did not do it correctly.

Apache is listening on port 80 and 81.

When I added that, and had a friend download a file from 80, it was going at 15kb/sec (this is the cap by my ISP), however, when downloading at 81 after adding the code it was 300kb/sec.

Why does my port 80 download so slow compared to my 81? It's my ISP. They have a cap on port 80 but not other ports.

This is the reason I wish to redirect the port. Don't know if it's possible.

Thanks.

edit: Ok, I fixed the problem by adding a virtual host for port 80. But I'm still interested in this way now, if its possible I'd like to learn how to still add it. Thanks.


All times are GMT -5. The time now is 10:33 PM.