Networking Forums

Networking Forums > Computer Networking > Linux Networking > Converting pseudo-tty to IP Address

Reply
Thread Tools Display Modes

Converting pseudo-tty to IP Address

 
 
Tim Underwood
Guest
Posts: n/a

 
      10-14-2003, 07:51 PM
How can I easily get the IP Address of a given terminal connected via a
pseudo-tty?

In other words, if I issue the 'tty' command, and receive /dev/pts/1, how
can I convert /dev/pts/1 into normal dotted notation?

I don't want to have to build a hosts file, DNS, etc.


 
Reply With Quote
 
 
 
 
Puff Addison
Guest
Posts: n/a

 
      10-14-2003, 08:42 PM
Tim Underwood wrote:

>How can I easily get the IP Address of a given terminal connected via a
>pseudo-tty?
>
>In other words, if I issue the 'tty' command, and receive /dev/pts/1, how
>can I convert /dev/pts/1 into normal dotted notation?
>
>I don't want to have to build a hosts file, DNS, etc.
>
>
>
>

I assume you mean DNS name format, ttys do not normally have IP addresses

tty | awk 'BEGIN{FS="/";}{print $4 "." $3 "." $2 ".";}

or

tty| tr "/" "."| cut -c 2-

if you are happy with 0.pts.dev

--
J. D. Addison
email (E-Mail Removed)

 
Reply With Quote
 
Leon The Peon
Guest
Posts: n/a

 
      10-15-2003, 01:22 AM

"Tim Underwood" <(E-Mail Removed)> wrote in message
news:vtYib.108471$(E-Mail Removed). net...
> How can I easily get the IP Address of a given terminal connected via a
> pseudo-tty?
>
> In other words, if I issue the 'tty' command, and receive /dev/pts/1, how
> can I convert /dev/pts/1 into normal dotted notation?
>
> I don't want to have to build a hosts file, DNS, etc.



pseudo-tty's are used for all sorts of things, not just network logins.

I think you can trust the output of 'w' , 'who'.

These are created from entries in /etc/wtmp, so you trust this record is
accurate.

but of course you might not want to do that.


You have to realise that your network login has two processes.

one telnetd (or rshd, sshd ) and one shell (bash, sh, ash, zsh ,whateversh )

The psuedotty's are how these two processes communicate - the pseudotty has
to be there because the shell and the rest of the system expects a tty, and
the tty has to control the processes (telnetd and sh ) and so it has to be
implemented in the kernel.

So to find the ip address of a connection, scan /proc/XXXX (XXXX being
positive integers) for the process with the backend pseudo-tty open. thats
the telnetd or equiv. Then read its file list to find the file handle for
the network connection. then you can use other proc tables to map this file
handle to a remote ip address. netstat read this data already? but it doesnt
deal with tty's.











 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Windows 2003 SP2 - removed IPv6 still showing pseudo adaptors Matthew Millers Windows Networking 6 10-16-2008 12:16 PM
Converting TCP IP Network from DSL to T1 Need Help Tom Windows Networking 4 07-29-2008 11:01 AM
Network Pseudo-device question George Linux Networking 5 05-23-2005 06:25 PM
Help with converting .dbx files Jerry Litt Windows Networking 3 10-20-2003 12:13 PM
Converting from NTL to ADSL Adrian Daniels Broadband 2 08-15-2003 11:26 AM



1 2 3 4 5 6 7 8 9 10 11