Subject: Re: determining originating IP address of current rsh session
To: Laine Stump <lainestump@rcn.com>
From: Simon Burge <simonb@netbsd.org>
List: netbsd-users
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
> rot...
>
> 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 172.73.42.244:514 <-> 172.73.42.42:1011
simonb tcsh 5209 17* internet stream tcp c05a16e0 172.73.42.244:514 <-> 172.73.42.42:1011
simonb tcsh 5209 18* unix stream c060f2c0 <-> c060f3c0
simonb tcsh 5209 19* internet stream tcp c05a16e0 172.73.42.244:514 <-> 172.73.42.42:1011
In this case I'm rsh'ing from 172.73.42.42 to 172.73.42.244. You
could then use some awk to grab the relevent fields.
Something like Andrew's getpeer.c is probably easier to use :-)
Simon.