Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

how to get telnet client IP address

617 views
Skip to first unread message

Aaron_...@jud.ca.gov

unread,
Apr 7, 1998, 3:00:00 AM4/7/98
to

From the server, I need to get the IP address of the client who has
initiated a telnet session. 'who -m' works USUALLY, but there are some
situations where it returns a non-resolvable name. What is the best
way to determine the IP address of the telnet client?

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading

System Administrator

unread,
Apr 7, 1998, 3:00:00 AM4/7/98
to

well, off the top of my head..a good start would be:

netstat -n | grep :23

how you parse it out after that is up to you.

-Cygnus
---------------------------------------------------------------------------
Anthony J. Biacco Network Administrator/Engineer
.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-.
"The only way to predict the future, is to invent it."
.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-.
ad...@intergrafix.net cyg...@ncohafmuta.com
http://cygnus.ncohafmuta.com/
---------------------------------------------------------------------------

Harald Radke

unread,
Apr 7, 1998, 3:00:00 AM4/7/98
to

Aaron_...@jud.ca.gov wrote:

> From the server, I need to get the IP address of the client who has
> initiated a telnet session. 'who -m' works USUALLY, but there are some
> situations where it returns a non-resolvable name. What is the best
> way to determine the IP address of the telnet client?
>
> -----== Posted via Deja News, The Leader in Internet Discussion ==-----
> http://www.dejanews.com/ Now offering spam-free web-based newsreading

Well...what about tcp wrappers like tcpd ?? It´ll log the IP/Name of a
client via syslog...
See /etc/inetd.conf ...

Harry


David Annis

unread,
Apr 7, 1998, 3:00:00 AM4/7/98
to

On Tue, 07 Apr 1998 12:28:56 -0600, Aaron_...@jud.ca.gov wrote:

>From the server, I need to get the IP address of the client who has
>initiated a telnet session. 'who -m' works USUALLY, but there are some
>situations where it returns a non-resolvable name. What is the best
>way to determine the IP address of the telnet client?
>
>-----== Posted via Deja News, The Leader in Internet Discussion ==-----
>http://www.dejanews.com/ Now offering spam-free web-based newsreading

A simple script:

#!/bin/sh
xtty=`tty | cut -c6-15`
who | grep -w $xtty | tr -d '()' | awk '{ print $6 }'

If the IP address resolves to a name, you get that instead of the
number.
***************************************************************
** Dave Annis * With age comes wisdom, **
** Kohler Co. * if you stay awake along the way. **
***************************************************************

Wayne J. Rasmussen

unread,
Apr 8, 1998, 3:00:00 AM4/8/98
to

Aaron_...@jud.ca.gov wrote:
: From the server, I need to get the IP address of the client who has
: initiated a telnet session. 'who -m' works USUALLY, but there are some
: situations where it returns a non-resolvable name. What is the best
: way to determine the IP address of the telnet client?

try:

last loginname

Villy Kruse

unread,
Apr 8, 1998, 3:00:00 AM4/8/98
to

>try:

>last loginname


If who -m works most of the time it means the telnetd has stored this
information in the wtmp file. If the ip number is not resolvable
it means that the information was not available. Basically, the telnetd
program is the only point where the ip number as well as the tty device
name is known at the same time. Thus, if telnetd does not store this
information in wtmp it can be very hard to get the information otherwise.
You can get all the tcp connections from the netstat command, but the
information is usually not related to any process, let alone, terminal
device name. This, of course is no problem if you have only one remote
telnet connection, butif you had 50 or 100 telnet connection it would be
hard to trace that back to terminal names. If you have a working lsof on
your system you can get from login shell using the ppid to locate the
right telnetd process. The lsof program can the tell what tcp connection
this telnetd process has open.

Villy


System Administrator

unread,
Apr 8, 1998, 3:00:00 AM4/8/98
to

In comp.unix.questions Wayne J. Rasmussen <w...@netcom.com> wrote:
> Aaron_...@jud.ca.gov wrote:
> : From the server, I need to get the IP address of the client who has
> : initiated a telnet session. 'who -m' works USUALLY, but there are some
> : situations where it returns a non-resolvable name. What is the best
> : way to determine the IP address of the telnet client?

> try:

> last loginname

but he only wants the *IP*, not the alphanumeric

Wayne J. Rasmussen

unread,
Apr 8, 1998, 3:00:00 AM4/8/98
to

System Administrator (ad...@athena.intergrafix.net) wrote:

: In comp.unix.questions Wayne J. Rasmussen <w...@netcom.com> wrote:
: > Aaron_...@jud.ca.gov wrote:
: > : From the server, I need to get the IP address of the client who has
: > : initiated a telnet session. 'who -m' works USUALLY, but there are some
: > : situations where it returns a non-resolvable name. What is the best
: > : way to determine the IP address of the telnet client?

: > try:

: > last loginname

: but he only wants the *IP*, not the alphanumeric


I have this setup on lots of system for lots of users and It works for me.


last `whoami` -1 | awk '{ print $3 }' -

wayne


Robert Garskof

unread,
Apr 9, 1998, 3:00:00 AM4/9/98
to

This is great and almost solves a problem I have. I would like to pump
the output of;

last `whoami` -1 | awk '{print $3}' -

to

export DISPLAY=

This is all fine execpt the IP address is never FULLY qualified on my
AIX 4.1.5 box. I get 151.109.162:0.0 for 151.109.162.211:0.0.

Whats up with that?

Any ideas?

Thanks in advance!

--


/*********************************************************************\
* Robert Garskof | robert.gar...@snet.com *
* ICAS Development Team | rgarsko...@cris.com *
* Southern New England Telephone | *
*-------------------------------------------------------------------*
* Remove 'nospam' from either e-mail address to e-mail *
\*********************************************************************/

Mr Cheuk Kong Lo

unread,
Apr 11, 1998, 3:00:00 AM4/11/98
to

System Administrator (ad...@athena.intergrafix.net) wrote:

: > last loginname

: but he only wants the *IP*, not the alphanumeric

who -m -n usually works.

--
Chris Lo mailto: chri...@prudential.com.hk
System Administrator/Informix DBA mailto: ck...@cklo.hk.super.net
The Prudential Assurance (HK) Co. Ltd mailto: ck...@hk.super.net
==============================================================================
-- Linux + FreeBSD + HPUX + Solaris + AIX
==============================================================================
#include <std/disclaimer.h>

0 new messages