The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
Google UNIX.COM


High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
ip address of a client ka2d2 IP Networking 6 11-26-2007 02:44 PM
Getting IP Address of a client fayette High Level Programming 0 03-24-2006 11:27 AM
client IP address rolly UNIX for Dummies Questions & Answers 2 03-17-2005 06:14 PM
Client Ip Address ovingtond IP Networking 1 09-15-2003 02:45 PM
IP address of telnet client vtran4270 UNIX for Dummies Questions & Answers 1 09-12-2002 01:34 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 03-18-2006
Technorati Master
 

Join Date: Mar 2005
Location: Large scale systems...
Posts: 2,610
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.
Reply With Quote
Forum Sponsor
  #2  
Old 03-18-2006
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,616
Use lsof on the parent of the shell.
Reply With Quote
  #3  
Old 03-20-2006
Technorati Master
 

Join Date: Mar 2005
Location: Large scale systems...
Posts: 2,610
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!!!
Reply With Quote
  #4  
Old 03-20-2006
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,616
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.
Reply With Quote
  #5  
Old 03-21-2006
Technorati Master
 

Join Date: Mar 2005
Location: Large scale systems...
Posts: 2,610
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.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 07:00 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0