Need IP port forwarding to access an internel service running on an internal machine
Posted
by
appleluo
on Server Fault
See other posts from Server Fault
or by appleluo
Published on 2012-09-11T16:39:29Z
Indexed on
2012/10/09
3:39 UTC
Read the original article
Hit count: 447
I am trying to configure iptables to do port forwarding for certain request. The scenario is like this:
Login node A can be accessed from outside Compute node B that running the service can be accessed from A but not from outside. I want to set up iptables so that a request for the service on B from outside can be accessed through A.
A has two ethernet ports: Internal eth0, with ip internal_A and External eth1, with ip external_A.
B has 1 ethernet port, internal eth0. let's say its ip is internal_B
The service listens to internal_B:5900. We open external_A:10000 for user access.
I configure my iptables with the following commands:
echo 1> /proc/sys/net/ipv4/ip_forward
/sbin/iptables -P FORWARD ACCEPT
/sbin/iptables -t nat -A POSTROUTING -j MASQUERADE
/sbin/iptables -A PREROUTING -p tcp -t nat --dport 10000 -j DNAT --to-destination interal_B:5900
/sbin/iptables -A OUTPUT -p tcp -t nat -d external_A --dport 10000 -j DNAT --to-destination internal_B:5900
But it didn't work. Can anybody help me?
© Server Fault or respective owner