I need to establish a Socket connection (TCP) between two hosts (say host1 and host2) in Java. But looks like I can’t do that because of a firewall. Though there’s a third host (say host3) which is accessible from both host1 and host2 and I think can be used as an intermediate for this connection.
So basically, I want to send a request from host1 (client) to host3, which redirects my request to host2 (server).
Could you please let me know how can this be achieved?
Thanks in advance!
You could establish a SSH tunnel with
and then connect from host1 to host3 on port 4321. This effectively gets redirected to port 6523 on host2.
A similiar option could be to have
sshprovide a SOCKS server.and then use
curlinstead ofwget.Then you can do
(untested,
--socks4aand--socks5could be an option as well…)This
sshcommand creates a SOCKS server locally which tunnels the connection attempts to the ssh server, which in turn executes them.