JProfiler, SSH Tunnel, and NAT Networks
Posted in Techno Stuffs on August 21st, 2005
Finally, after some tinkering and trial and error.. I finally made an SSH tunnel for JProfiler between NAT networks to work.. ![]()
Here’s the scenario. We have a remote server where a java based web application runs and we want to monitor the said application using JProfiler to test it for memory leaks.
I am now facing the following challenges:
1. We have no root access to the server.
2. We have no administrative rights to the network and firewall, thus we can’t open and close access ports at will.
3. The server is behind a firewall and access to it is only done through NAT.
Here are the only things I have:
1. SSH access to the remote server using a normal user account.
2. Read/Write permission to the application server files.
3. A cup of coffee and a pack of cigarette. Hehehehe!
The remote server have an internal IP, let’s say 192.168.128.7 and it can be accessed from the outside using a NAT external IP, like 203.192.28.31. So the problem now is, how can I open up a port in the remote server where the JProfiler server integration script would listen for connection and in turn connect my JProfiler program through it? Well how else, through a SSH tunnel of course! ![]()
I tried running the following SSH tunnel command from one of my Solaris test servers (using the default JProfiler port 8849) :
ssh -g -N -L 8849:203.192.28.31:8849 user@203.192.28.31
This should be the normal setup in which my test server should establish a SSH connection to the remote server, listen to port 8849 and then forward any connections to it to port 8849 of the remote server using the SSH tunnel.
For some reason this doesn’t seem to work, but for HTTP ports (80) and other access ports it seems to work but for JProfiler even if I don’t use default port 8849, the remote server doesn’t seem to receive the forwarded request. The only culprit I can think of here is the NAT setup of the remote server.
After much thinking, I came up with the idea that instead of using the external NAT IP of the remote server in ssh forwarding, I would just use the internal IP and just use the external IP to connect the test server to the remote server through SSH. Here’s the command I used:
ssh -g -N -L 8849:192.168.128.7:8849 user@203.192.28.31
Walaaah! It worked and I was able to connect. ![]()
I guess…the coffee and pack of cigarette did the trick .. ![]()