in reply to telnet ip address

This may not be feasible in your situation, but if you migrate from telnet to openssh, you'll get an easily parsable SSH_CLIENT environment variable, and a few other benefits as well.
$ env | grep SSH SSH_TTY=/dev/pts/44 SSH_CLIENT=172.19.69.68 1850 22