Didn't you read what I just said? I already mentioned that I see the environment variable SSH_CONNECTION with the remote ip address in it. If you noticed that you have this, then use it. If you don't have it, it's probably the fault of your SSH server or maybe a configuration script on your server deletes it.