vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| |||
| ----- Original Message ----- From: "Brandt Eppler" <beppler@comcast.net> Newsgroups: comp.unix.sco.misc To: <sco-misc@lists.celestial.com> Sent: Tuesday, September 13, 2005 7:08 PM Subject: IP Address > Is there a way to determine the IP address that a telnet session came > from? > SCO v5.07 >From inside said session? (like from inside a script or app the user will run, or in their .profile, or in /etc/profile) or from outside the session? (like a cron job or a reporting util a sys admin or other priviledged user will want to run to see everyone elses IP's sometimes) who -u all connections (who -uH to include a header) who -um your current connection (who -umH to include a header) finger -wf all connections (finger -w to include a header) caveats & notes: Displays hostnames if possible via the normal rules (ie, if /etc/resolv.conf exists, it's used, which usually means it tries dns, then /etc/hosts) If the hostname is very long, it gets chopped off and so the result may not be useful. (it may be useful if you are simply trying to establish if the user is coming from a known local lan IP or anywhere else, and don't really need to be able to for example, initiate connections back to the user to send print jobs) If the user is connecting via facetwin instead of telnet, then facetwin has the very annoying feature of putting the users windows netbios computer name in the who output which is pretty much useless and horribly broken. However, facetwin also has another feature that can be used to offset the broken who output, it supplies several environment variables in the users session. One of these is: FACETWINIPADDR which is set to the ip the user came from. If you need to determine the users IP from outside their session (say from a cron job or from a sys admin monitoring type of script) then I don't know what you can do other than put stuff in /etc/profile to test for FACETWINIPADDR, and if it exists, to write a tmp file named after the users tty, and in the file put the IP, and then those files can be read from other processes outside of the users session. If the user is connecting via ssh (openssh) instead of telnet, then openssh provides an env variable SSH_CLIENT, which has the IP the user came from (not the hostname) If the user is connecting via the console, xterms in X on the console, serial terminals, & dialin modems, then there is no IP so you want to check the tty (also in both the who and finger outputs) at the same time and depending on that, maybe sometimes skip trying to determine an IP. Brian K. White -- brian@aljex.com -- http://www.aljex.com/bkw/ +++++[>+++[>+++++>+++++++<<-]<-]>>+.>.+++++.+++++++.-.[>+<---]>++. filePro BBx Linux SCO FreeBSD #callahans Satriani Filk! |
| |||
| Brian K. White a écrit : >----- Original Message ----- >From: "Brandt Eppler" <beppler@comcast.net> >Newsgroups: comp.unix.sco.misc >To: <sco-misc@lists.celestial.com> >Sent: Tuesday, September 13, 2005 7:08 PM >Subject: IP Address > > > > >>Is there a way to determine the IP address that a telnet session came >>from? >>SCO v5.07 >> >> > >>From inside said session? (like from inside a script or app the user will >run, or in their .profile, or in /etc/profile) >or from outside the session? (like a cron job or a reporting util a sys >admin or other priviledged user will want to run to see everyone elses IP's >sometimes) > >who -u all connections (who -uH to include a header) >who -um your current connection (who -umH to include a header) >finger -wf all connections (finger -w to include a header) > >caveats & notes: >Displays hostnames if possible via the normal rules (ie, if /etc/resolv.conf >exists, it's used, which usually means it tries dns, then /etc/hosts) > >If the hostname is very long, it gets chopped off and so the result may not >be useful. (it may be useful if you are simply trying to establish if the >user is coming from a known local lan IP or anywhere else, and don't really >need to be able to for example, initiate connections back to the user to >send print jobs) > >If the user is connecting via facetwin instead of telnet, then facetwin has >the very annoying feature of putting the users windows netbios computer name >in the who output >which is pretty much useless and horribly broken. However, facetwin also has >another feature that can be used to offset the broken who output, it >supplies several environment variables in the users session. One of these >is: FACETWINIPADDR which is set to the ip the user came from. If you need to >determine the users IP from outside their session (say from a cron job or >from a sys admin monitoring type of script) then I don't know what you can >do other than put stuff in /etc/profile to test for FACETWINIPADDR, and if >it exists, to write a tmp file named after the users tty, and in the file >put the IP, and then those files can be read from other processes outside of >the users session. > >If the user is connecting via ssh (openssh) instead of telnet, then openssh >provides an env variable SSH_CLIENT, which has the IP the user came from >(not the hostname) > >If the user is connecting via the console, xterms in X on the console, >serial terminals, & dialin modems, then there is no IP so you want to check >the tty (also in both the who and finger outputs) at the same time and >depending on that, maybe sometimes skip trying to determine an IP. > >Brian K. White -- brian@aljex.com -- http://www.aljex.com/bkw/ >+++++[>+++[>+++++>+++++++<<-]<-]>>+.>.+++++.+++++++.-.[>+<---]>++. >filePro BBx Linux SCO FreeBSD #callahans Satriani Filk! > > > > > Hi, or "who -x" if still exists on OSR 5.07 ? (only have up to OSR 5.06 boxes !). F. STOCK -- **************** Enlever ".remove-me" dans l'adresse. Remove ".remove-me" from e-mail. **************** |
| |||
| ----- Original Message ----- From: "Frédéric STOCK" <juramont.remove-me@club-internet.fr> Newsgroups: comp.unix.sco.misc To: <distro@jpr.com> Sent: Wednesday, September 14, 2005 2:22 AM Subject: Re: IP Address > Brian K. White a écrit : > .... >>----- Original Message ----- >>From: "Brandt Eppler" <beppler@comcast.net> >>Newsgroups: comp.unix.sco.misc >>To: <sco-misc@lists.celestial.com> >>Sent: Tuesday, September 13, 2005 7:08 PM >>Subject: IP Address >> >>>Is there a way to determine the IP address that a telnet session came >>>from? >>>SCO v5.07 >> .... >>who -u all connections (who -uH to include a header) >>who -um your current connection (who -umH to include a header) >>finger -wf all connections (finger -w to include a header) .... > or "who -x" if still exists on OSR 5.07 ? (only have up to OSR 5.06 boxes > !). > F. STOCK Gahh, you're so right. It's there. And my scripts all use it. And I don't know why I didn't write it. Sould have been: who -ux all connections (who -uxH to include a header) who -umx your current connection (who -umxH to include a header) Here is "tellip", a script all my boxes use, right from /etc/profile (indirectly by way of another script called amilocal) to see if the user is connecting from local or remote. It ends up setting a variable AMILOCAL and various things hinge off that, default printer destination and ip-to-the-server for starters. You can see the sco part of the case statement uses -umx . # cat /u/magprogs/tellip #!/bin/ksh # # tellip - "Tell IP" # prints the IP or Hostname that the user is connecting from. # mostly used in other scripts to determine non-static addresses. # # can be run on SCO, Linux, FreeBSD # # Brian K White - brian@aljex.com - Aljex Software # facetwin screws up "who" so try to use facetwin variable instead. [ -n "${FACETWINIPADDR}" ] && { echo "${FACETWINIPADDR}" ; exit ; } # "who" tries to show hostname but chops long names, try to use ssh variable. [ -n "${SSH_CLIENT}" ] && { echo "${SSH_CLIENT}" |awk '{print $1}' ; exit ; } case `uname -s` in Linux) who -m |cut -d\( -f2 |cut -d\) -f1 ;; FreeBSD) who |cut -d\( -f2 |cut -d\) -f1 ;; SCO_SV) who -umx | awk '{ print $6 }' ;; esac -- Brian K. White -- brian@aljex.com -- http://www.aljex.com/bkw/ +++++[>+++[>+++++>+++++++<<-]<-]>>+.>.+++++.+++++++.-.[>+<---]>++. filePro BBx Linux SCO FreeBSD #callahans Satriani Filk! |