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~~
|
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 |
hi hakcenter and all, sorry, i forget to tell that the pub IP is dynamic, so......... anythings i should do it again? thanks.... :)
|
actually no, i wrote that to support dhcp wan.
it preroutes anyone that is not on your subnet to that ip |
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. |