- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: HPUX11.11 telnet connection, addressed ip-numb...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2003 01:25 AM
08-06-2003 01:25 AM
we run some applications on a rp5470 and want to start an application depending on the chosen incoming ip-address of the host.
How can I check from which incoming host ip address the user session started.
Any ideas welcome
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2003 01:35 AM
08-06-2003 01:35 AM
Re: HPUX11.11 telnet connection, addressed ip-number on host
Who -um creates an output with username and ip-adress for the current session.
who -um | awk '{ print $7'} prints the ip-adress for the current session.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2003 01:36 AM
08-06-2003 01:36 AM
Re: HPUX11.11 telnet connection, addressed ip-number on host
something like this in your .profile.
http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x25f338bcbbbb2b478d68632760cdba9f,00.html
Hope it helps,
Robert-Jan.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2003 01:37 AM
08-06-2003 01:37 AM
Re: HPUX11.11 telnet connection, addressed ip-number on host
I guess you're putting this into the .profile/.login/.cshrc file of the user?
You could possibly do something with who -R? That usually tells you what machine a particular user is logged in from. However it would complicate things a bit if there are multiple users logged in with the same userid similtaneously, you'd have to work out which telnet session you're on and pick out the entry from who -R with that. Use cut to pick out a particular field or fields of the who -R output.
Not sure whether whoami outputs the tty, have an idea it does but can't quite picture the output and don't have access to a HPUX box just now.
If you sort that out you could put a case statement into the .login/.cshrc/.profile that would start the application depending on the IP address it got from the who -R command.
Hope that helps?
Kevin.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2003 01:42 AM
08-06-2003 01:42 AM
Re: HPUX11.11 telnet connection, addressed ip-number on host
# who u
or, see who login as a particular user:
# finger root
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2003 03:29 AM
08-06-2003 03:29 AM
Re: HPUX11.11 telnet connection, addressed ip-number on host
I do not wnt to know where from (client ip address) somebody wants to connect, but to what ip-address on the host they connect.
who -u or -R ... gives me the source ip address of the client.
we have some network ports (4-port network card) where we assigned different ip-adresses to it.
Now I want to know, via which host-ipaddress the client is comming in.
This makes it possible to give the users one icon (~ destinatin ipaddress) per application on their desktop. (some users have to use more than one application on this host)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2003 03:56 AM
08-06-2003 03:56 AM
Re: HPUX11.11 telnet connection, addressed ip-number on host
Once you get the client IP address ( as suggested before ), you can run "netstat -a | grep client_IP" and look for the Ip of your hosts ( IP or alias of that lan card ).
Hope this helps.
Regards,
Zigor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2003 06:52 AM
08-06-2003 06:52 AM
Re: HPUX11.11 telnet connection, addressed ip-number on host
Ron
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2003 07:52 AM
08-06-2003 07:52 AM
Re: HPUX11.11 telnet connection, addressed ip-number on host
Zigor and Ron are very close, but I cannot distinquish between 2 or more connections from one client (e.g. 2 different applications or 2 sessions, same application).
the only clue may be the not empty send-Q of netstat -an e.g. the output of the following statement:
netstat -an |grep $(who -um | awk '{ print $8}')
tcp 0 2 193.81.97.5.23 193.228.206.84.1803 ESTABLISHED
tcp 0 0 192.46.193.163.23 193.228.206.84.4645 ESTABLISHED
tcp 0 0 192.46.193.163.23 193.228.206.84.1678 ESTABLISHED
see parameter 3 (2) in 1??st line.
but this may not be the only active send-Q from one client?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2003 11:12 PM
08-06-2003 11:12 PM
Re: HPUX11.11 telnet connection, addressed ip-number on host
Ron, thanks for the correction.
Franz, maybe I still not understand the question, but I think you can distinguish between connections from one client.
tcp 0 2 193.81.97.5.23 193.228.206.84.1803 ESTABLISHED
tcp 0 0 192.46.193.163.23 193.228.206.84.4645 ESTABLISHED
tcp 0 0 192.46.193.163.23 193.228.206.84.1678 ESTABLISHED
In the netstat output you can see that the client with IP 193.228.206.84 has three telnet sessions established, two of them against server IP 192.46.193.163 and one against server IP 193.81.97.5.
So, I think you need to use the TCP port used by the client to distinguish between the connections. Suppose that you have no connections from the client i.e 193.228.206.xxx, you can edit the .profile and put the necessary lines to get the client IP, server IP used, TCP port used by the client, and terminal used by client ( TERMI=`who -um | awk '{ print $2}'`. You can store all that info in a line in a temp file. In this way, when the same client connects again ( now there are two sessions ) you only need to search in that "log" file to distinguish between connections from the same client ( now you know which is the previous connection ).
Finally, you can edit the .logout file and put the necessary lines to clean the "log" file when a user disconnects ( i.e looking for the terminal used ).
It??s only an idea ( perhaps little complicated ), and I have no tested ... maybe this is a piece of nonsense ;-)
Kind regards,
Zigor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2003 06:45 AM
08-07-2003 06:45 AM
Solution1. Its easy with ssh as, sshd sets an env var "SSH_CLIENT" which includes the tcp port numbers (src,dest) which can be used with netstat -na output to determine the dest IP address.
2. For telnet, it was a bit harder. Once inside the /etc/profile, there is no direct network information available as the session has been handed off to a pseudo tty which passes data back and forth with the telnetd spawned for the session.
What I did was use the open soruce tcp wrappers code to wrap telnetd spawns from inetd. Now, the actual code was modified to collect the dest IP address from sockaddr structure representing the connection and dump it to a tmp file keyed by pid. Later, in /etc/profile, this file is found via the sh's PPID. The information is collected at the end of function sock_host in module socket.c.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2003 02:41 AM
08-08-2003 02:41 AM
Re: HPUX11.11 telnet connection, addressed ip-number on host
Zigor, thank you for the input. But there is the problem of assigning the right address.port number to the actual telnet connection. The missing link for me is the connection of the port# and the device telnet is assigned to. At least I could get no reliable result with:
netstat -an |grep $(who -um | awk '{ print $8}')| awk ' { if ($3 != "0") {print $4} } '| awk '{ FS="."; { print $1"."$2"."$3"."$4 }}'
But maybe I just got the hint.
I am trying lsof, a HP-utility, that seems to be somewhat in the direction Darren had solved his Problem.
Darren, this lsof seems to be my "missing link". Here I should get the process-id of the current telnet process, the client-ip and host-incoming-ip.
I will post, if this solution works.
Kind regards,
Franz
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2003 07:37 AM
08-19-2003 07:37 AM
Re: HPUX11.11 telnet connection, addressed ip-number on host
my solution for this problem is with lsof, list open files.
get process number of current telnet session
grep $(ps |grep telnetd | awk '{ print $2 }')
as search criteria for grep on lsof output, and formatting with awk for getting the dest. address we looked for.
sample script see below
...........
# check welche Host-IP-Adresse adressiert wurde
ZIELA="$(lsof -i -n | grep $(ps |grep telnetd | awk '{ print $2 }')|awk '{ if ( NR == 1) print $9 }' | awk '{ FS=":"; { print $1}}')"
GR=`groups`
echo $ZIELA $GR
case ${ZIELA} in
"199.43.177.148" )
if [ -n `echo $GR |grep proalpha` ]
then
echo "ILS wurde gewaehlt"
SYST=ILS; echo $SYST
### . /home/prof/.usprofile
fi
;;
"*" )
echo "NIX wurde gewaehlt $ZIELA"
exit
;;
esac # case ZIELA
...........
Thank you for your help
Franz