Subject: Re: determining originating IP address of current rsh session
To: Laine Stump <email@example.com>
From: Simon Burge <firstname.lastname@example.org>
Date: 03/19/2000 12:06:09
Laine Stump wrote:
> 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
> 10.0.0.1 and I give the command "rsh 192.168.0.1 whatsmyip", it should
> display "10.0.0.1". (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.
balrog:~ 2742> rsh wincen fstat -p '$$'
USER CMD PID FD MOUNT INUM MODE SZ|DV R/W
simonb tcsh 5209 wd /home 4096 drwxr-xr-x 3584 r
simonb tcsh 5209 16* internet stream tcp c05a16e0 22.214.171.124:514 <-> 126.96.36.199:1011
simonb tcsh 5209 17* internet stream tcp c05a16e0 188.8.131.52:514 <-> 184.108.40.206:1011
simonb tcsh 5209 18* unix stream c060f2c0 <-> c060f3c0
simonb tcsh 5209 19* internet stream tcp c05a16e0 220.127.116.11:514 <-> 18.104.22.168:1011
In this case I'm rsh'ing from 22.214.171.124 to 126.96.36.199. You
could then use some awk to grab the relevent fields.
Something like Andrew's getpeer.c is probably easier to use :-)