Summary: How do you determine the IP address you connected with?

From: Edward Nowlan <Edward.S.Nowlan_at_williams.edu>
Date: Tue, 08 Jun 1999 10:42:37 -0400 (EDT)

I received quite a few response, rather quickly, thanks to:

George Gallen <ggallen_at_slackinc.com>
"C.Ruhnke" <i769646_at_smrs013a.mdc.com>
"David J. DeWolfe" <sxdjd_at_java.sois.alaska.edu>
Amy Skowronek <amy_at_aloha.nascom.nasa.gov>
Gwen Pettigrew <gwen_at_itg.cam.ac.uk>
Sean O'Connell <sean_at_stat.Duke.EDU>
Paul A Sand <pas_at_unh.edu>
Rob Mayfield <Rob.Mayfield_at_digital.com>
Wayne Sweatt <sweatt_at_dps.state.nm.us>

I choose to use the following to get the IP address and used arp ip-address to
get the ethernet address. I am lucky that we are a flat network, no subnets so
I can arp for my address, otherwise arp would return the router's address:

who -Mm | awk '{print $6}' | sed s/\(// | sed s/\)//


Other responses included:
------------------------------------------------------------------

TTY=`tty | cut -b 9-`
HOSTNAME="`w | grep $TTY | paste -s - | awk '{print $3}'`"

------------------------------------------------------------------

lsof (No specifics were given and as of yet I have not tried this one)

------------------------------------------------------------------

mytty=`tty | sed -e 's/\/dev\///' `
REMOTEHOST=`who -M | grep ${mytty} | awk -F \( '{ print $2 }' | sed -e 's/)//'`

If using ssh environment variable SSH_CLIENT (IP Address) and SSH_TTY (tty)

------------------------------------------------------------------

If you have tcsh then the environment variable REMOTEHOST


------------------------------------------------------------------

who -M | awk '{print $6}' | tr -d '[()]'
Received on Tue Jun 08 1999 - 15:08:36 NZST

This archive was generated by hypermail 2.4.0 : Wed Nov 08 2023 - 11:53:39 NZDT