LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Problem with Port forwarding :( (https://www.linuxquestions.org/questions/linux-networking-3/problem-with-port-forwarding-310327/)

aronnok 04-06-2005 08:12 AM

Problem with Port forwarding :(
 
hi there!
Something is wrong. I am not able to forward my ports to some others server's different port. My idea is, i am using a gateway, which has two NIC. ( eth0 X.X.12.106; eth1 X.X.12.108 ). etho is connected with internet. i have a webserver running behind my gateway which IP is X.X.12.109.
All i need is, my webserver will run on a different port. suppose 90 ( instead of 80 ). so, when some one will try for www.abc.com ( X.X.12.109 ), my gateway server will automatically redirect them to ( X.X.12.109:90 ).

i have used the following method. but due to some reason it failed. :(

/sbin/iptables -t nat -A PREROUTING -p tcp -i eth0 -d 69.88.12.109 --dport 80 -j DNAT --to 69.88.12.109:90

/sbin/iptables -t nat -A PREROUTING -p tcp -i eth1 -d 69.88.12.109 --dport 80 -j DNAT --to 69.88.12.109:90

Can anybody help me?
thanx in advance.

Technoslave 04-06-2005 10:37 AM

First off, it doesn't help to x out your IP address, I don't know why people do this, it makes no sense and only compounds on the problem as the reader has to start mentally wrangling with what's going on.

However, I find it funny that later on you copy and paste the actual IP 69.88.12.109, good job!

I also find it funny that no one does a search on this subject to begin with. However, with the slow-ass search that's going on right now, I don't blame you.

So, much like monkeys who fling poo, I will continue to fling this answer out:

So, here's the example of port forwarding using iptables.

I have an internal server on port 10.0.0.2, running apache on port 80. I want to be able to reach it via port 81 from my gateway computer.

/sbin/iptables -t nat -I PREROUTING -p tcp -d 209.190.200.143 --dport 81 -j DNAT --to 10.0.0.2:80

You also have to do:

/sbin/iptables -I FORWARD -p tcp -d 10.0.0.2 --dport 80 -j ACCEPT

Good Luck.

Linux4Life 04-06-2005 02:16 PM

Yeah, what he said..

I don't have any problems with port forwarding because I use a telenet web based setup that's really easy to use. You just add the ports and their protocols and you're away with it.


All times are GMT -5. The time now is 09:05 AM.