LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-07-2006, 01:47 AM   #1
Dan8080
LQ Newbie
 
Registered: Jun 2006
Distribution: CentOS 4.3
Posts: 25

Rep: Reputation: 15
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
 
Old 06-07-2006, 03:17 AM   #2
dimsh
Member
 
Registered: Aug 2005
Distribution: Debian, Ubuntu, Fedora
Posts: 74

Rep: Reputation: 15
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

Last edited by dimsh; 06-07-2006 at 03:19 AM.
 
Old 06-08-2006, 12:43 AM   #3
Dan8080
LQ Newbie
 
Registered: Jun 2006
Distribution: CentOS 4.3
Posts: 25

Original Poster
Rep: Reputation: 15
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.

Last edited by Dan8080; 06-08-2006 at 12:47 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Is it not possible to route incomming port to another external port? ziggie216 Linux - Software 5 12-03-2005 07:16 PM
IP Route/IP Tables depam Linux - Networking 2 10-12-2005 03:10 PM
how to route internal Networks by IP tables? quazidaniel Linux - Networking 4 10-12-2005 11:32 AM
IP tables, forwarding port 25 bsherwood Linux - Networking 6 03-19-2005 06:20 PM
route locally generated traffic to ip:port to localhost:port maenho Linux - Software 2 03-11-2005 05:08 AM


All times are GMT -5. The time now is 02:52 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration