Retrieving IP address of Client from Server

Hi All,

When I connect to a unix server from a client machine,
how can I get the IP address of the client?

One way of retrieving IP address of client which initiates an active connection to the server is through /var/adm/utmpx file

upon login; client's IP address and other info would have been dumped into the file,

I just made use of utmpx structure to read the file with identification of line I am currently working and the loginname I was able to retrieve the client's IP address.

And that is how who command works

i just found one such similiar thread.
similiar thread

But I am searching for a method, to directly determine the client's IP address without depending on a file.

Any pointers on that!!!
Thanx in Advance.

Use lsof on the parent of the shell.

executing lsof on parent of the shell (login pid)
results in /dev/kmem error.

But how would this identify the client connected to the Server?

Thanks!!!

First you need a working lsof. The parent of the shell will be telnetd or something like that. It will have a connected socket to the client. lsof can display that socket.

Thanks for the reply Per,

shell spawned by login process which in turn is spawned by in.telnetd, where each instance of in.telnetd is dedicated to each of the login process. And in.telnetd should have the status of the active socket connection with the client which had initiated an active request.

And one more way, use
pfiles <in.telnetd pid>

since i dont have root permission i was just thinking of alternate way.