0

I am trying to forward a remote port from my server to my development machine. I have tried opening the port via iptables, but it is open only for 127.0.0.1.

If I login to the server using ssh and try curl http:127.0.0.1:FORWARDED PORT, the request is redirected to my local development machine. But the port is inaccessible to outside ip addresses.

Here is the output of netstat -an

tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:25              0.0.0.0:*               LISTEN     
tcp        0      0 **127.0.0.1:8099**          0.0.0.0:*               LISTEN     
tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN     
tcp        0      0 173.45.231.60:22        203.92.35.107:51994     ESTABLISHED
tcp6       0      0 :::22                   :::*                    LISTEN     
tcp6       0      0 ::1:8099                :::*                    LISTEN 

1 Answer 1

1

You need to set the optional bind_address to * E.g. if you're doing a local forward originating on the server (-L) then use ssh -L '*:8099:localhost:8099' mydevbox (note the quotes to keep the shell from expanding the asterisk)

8
  • I am doing a remote port forwarding. If my dev machine is accessible from outside, then I do not need this port forwarding stuff.
    – Jagira
    Nov 25, 2010 at 7:12
  • What are you using to do the port forward that works from localhost?
    – Ben Jencks
    Nov 25, 2010 at 7:16
  • ssh -R 8099:localhost:3000 MY_REMOTE_SERVER
    – Jagira
    Nov 25, 2010 at 7:17
  • Then do the equivalent for the -R option... -R *:8099:localhost:3000 Did you read the man page for the options you're using?
    – Ben Jencks
    Nov 25, 2010 at 7:19
  • 1
    You might need to turn on GatewayPorts on the server. By default it ignores bind_address in remote forwards.
    – Ben Jencks
    Nov 25, 2010 at 7:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .