LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   How can I do simple port forwarding on RH9? (https://www.linuxquestions.org/questions/linux-networking-3/how-can-i-do-simple-port-forwarding-on-rh9-72651/)

yetalu 07-14-2003 01:42 PM

How can I do simple port forwarding on RH9?
 
Machine A is the internet gateway (1 pub IP and 1 private IP) and i am running iptable on it now and it is working ok. I want all internet visit to machine A port 80 would automatically forward to machine B with private IP (it would be a web server). so... what should i do ? :confused: :confused: :confused: please help, many thanks~~

hakcenter 07-14-2003 01:49 PM

iptables -t nat -A PREROUTING -j DNAT -s ! LAN --dport 80 --to VIRTUALHOST

where lan is your local area network ip subnet
ex:
machine ips like 192.168.1.13 etc
LAN would be, 192.168.1.0/255.255.255.0
machine ips like 10.1.0.116 etc
LAN would be, 10.1.0.0/255.0.0.0

and VIRTUALHOST is the ip:80 of the virtual host
ex:
192.168.1.116:80

yetalu 07-14-2003 02:01 PM

hi hakcenter and all, sorry, i forget to tell that the pub IP is dynamic, so......... anythings i should do it again? thanks.... :)

hakcenter 07-14-2003 02:08 PM

actually no, i wrote that to support dhcp wan.

it preroutes anyone that is not on your subnet to that ip

wdingus 07-14-2003 07:44 PM

Something similar to this I've never been able to figure out is how to do this without NAT. More precisely how to re-direct a port to another machine in the same subnet.

For instance all access to port 3306(mysql) on 204.204.204.204 redirected to port 3307 on 204.204.204.205 or something like that. I can never seem to get this to work with iptables but can get more straightforward things like your example to work. Any ideas or suggestions?


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