SSH sets the environment variable SSH_CONNECTION to contain client IP address, client port number, server IP address, and server port number seperated by spaces.
You can use
Hidden content
to get the client's IP address. To get the DNS name use something like host or dig -x:
Hidden content...