Subject: determining originating IP address of current rsh session
To: None <>
From: Laine Stump <>
List: netbsd-users
Date: 03/18/2000 12:47:36
There must be a simple way to do this, and I'm just suffering from brain

I need for a shell script executed by rsh from another machine to tell
me the IP address of the originating machine. For example, if I'm on and I give the command "rsh whatsmyip", it should
display "". (In practice I'll use rexec so that the person
attempting to run the command (from some random IP address) is
authenticated, but the principle should be the same.

You may wonder why this is needed at all. The problem is that there is a
(1:1) NAT gateway between the two machines which translates the client's
IP address, and I need to find out what address the server machine
*thinks* the client is at.

My immediate use for this is for a simple script to run lbxproxy on a
NetBSD box and have it run on a Windows PC that is at the other end of
an encrypted (and 1:1 NATed) tunnel.

If this was a login session, I could *almost* get the info by grepping
for `tty` in the output of who, but that hostname is often truncated,
and anyway rsh doesn't give a login session, so it doesn't set tty and
doesn't show up in who.

(Oh, and don't bother lecturing me about how I should use ssh -
everything between the machines is already required to be encrypted and
authenticated with IPSec. Anyway, the X server I'm using has support for
rexec, but not ssh.)