SSH allowing remote hosts to connect to local forwarded ports

port-forwardingredhatrhel7selinuxssh

I'm currently facing an issue with a RHEL 7.0 regarding the ssh option -g (i.e remote hosts connection to local forwarded ports ).

I'm establishing a connection with port forwarding, from a server on myserver_ip address , with the usual command line :

ssh -o StrictHostKeyChecking=no user@server_fqn -L9090:other_server_ip:9080 -g

When I point my browser (or try to fetch something with curl I get a connection refused exception ) :

curl -X GET "http://myserver_ip:9090"
curl: (7) Failed to connect to myserver_ip port 9090: No route to host

If I do the same on a Ubuntu server it works perfectly, however on RHEL it simply does not work.

I suspected the firewall, selinux, even network connectivity.

In order to solve/troubleshoot this I've tried the following :

  • disabled the firewall (service firewalld stop)
  • checked that selinux manages the 9090 as valid http port (semanage port -l | grep 9090), it was ok
  • checked that the port is open via netstat ( netstat -alptn | grep 9090
    ) , seems ok , I've got an ssh process listening on 9090
  • checked that the server recieves the packets on port 9090 of the ehternet interface ( tcpdump -i ens192 'port 9090' -v ) , and indeed packets are recieved …

So basically it conformed that the system receives the requests on the interface, an ssh process is listening on all interfaces on the given port, however the ssh process does not forward packets to the other side …

I'm really out of leads for troubleshooting, so If you have any suggestions, please do not hesitate, I'd really appreciate some help.

Thanks,

Best Answer

Curl has already told you the answer. It's not about SSH, its not about firewalls, it's not about selinux.

no route to host

The machine where you are running curl does not know where it should send packets intended for (the ip address it associates with) my server_ip