How to identify ,through which IP address i'am connected ?

How to identify ,through which IP address i'am connected ?

Post by Karthikeyan » Fri, 08 Mar 2002 15:24:38



Hi ,

    I am having a Solaris box with 5 interfaces configured with
different IP addresses. When a client open a Telnet session with one of
the IP addresses, I need to identify  , to which IP address , the client
is 'telneting' .  Based on the IP address, i need to run some login
scripts.

Is the any command available for this ? Or can you give some pointers ,
to achieve it through C ?

Thanks ,
Karthikeyan S

 
 
 

How to identify ,through which IP address i'am connected ?

Post by David Schwart » Fri, 08 Mar 2002 15:55:08



> Hi ,

>     I am having a Solaris box with 5 interfaces configured with
> different IP addresses. When a client open a Telnet session with one of
> the IP addresses, I need to identify  , to which IP address , the client
> is 'telneting' .  Based on the IP address, i need to run some login
> scripts.

> Is the any command available for this ? Or can you give some pointers ,
> to achieve it through C ?

> Thanks ,
> Karthikeyan S

        It's not clear where you are trying to do this. Are you trying to do
this in the telnetd server itself (that is, are you modifying it?). Or
are you trying to write a login script? When you say, "I need to
identify", what program are you in?

        DS

 
 
 

How to identify ,through which IP address i'am connected ?

Post by Karthikeyan » Fri, 08 Mar 2002 16:10:15




> > Hi ,

> >     I am having a Solaris box with 5 interfaces configured with
> > different IP addresses. When a client open a Telnet session with one of
> > the IP addresses, I need to identify  , to which IP address , the client
> > is 'telneting' .  Based on the IP address, i need to run some login
> > scripts.

> > Is the any command available for this ? Or can you give some pointers ,
> > to achieve it through C ?

> > Thanks ,
> > Karthikeyan S

>         It's not clear where you are trying to do this. Are you trying to do
> this in the telnetd server itself (that is, are you modifying it?). Or
> are you trying to write a login script? When you say, "I need to
> identify", what program are you in?

>         DS

Hi ,

I don't want to change the telnetd. I want to identify using login scripts.

Thanks,
Karthikeyan S

 
 
 

How to identify ,through which IP address i'am connected ?

Post by David Schwart » Fri, 08 Mar 2002 16:30:17



> Hi ,

> I don't want to change the telnetd. I want to identify using login scripts.

        Your best bet is to change the telnet server and have it put whatever
information you need into the environment. Otherwise, you have to do
this a grossly ugly way. On Linux, I was able to pull it off by walking
parent processes until I found the telnet server, then walking its fd's
through /proc/<pid>/fd to find the socket and cross-referencing that in
the TCP socket table. Eww!

        DS

 
 
 

How to identify ,through which IP address i'am connected ?

Post by Chuck Dillo » Sat, 09 Mar 2002 00:21:29




> > Hi ,

> > I don't want to change the telnetd. I want to identify using login scripts.

>         Your best bet is to change the telnet server and have it put whatever
> information you need into the environment. Otherwise, you have to do
> this a grossly ugly way. On Linux, I was able to pull it off by walking
> parent processes until I found the telnet server, then walking its fd's
> through /proc/<pid>/fd to find the socket and cross-referencing that in
> the TCP socket table. Eww!

>         DS

An alternative to modifying telnetd would be to launch it via a wrapper between
it (telnetd) and inetd.  The wrapper could poke the required info into its
environment and then exec telnetd.  For example, in the ksh case the wrapper
might just set the ENV variable (or something ENV refers to).  I'm assuming
telnetd allows the existing environment to be passed to it's spawn.  If not the
wrapper could write the info to a well known location on disk that the
.login/.profile knows about.

-- ced

--
Chuck Dillon
Senior Software Engineer
Accelrys Inc., a subsidiary of Pharmacopeia, Inc.

 
 
 

How to identify ,through which IP address i'am connected ?

Post by Dan Merc » Sat, 09 Mar 2002 01:31:32




> Hi ,

>     I am having a Solaris box with 5 interfaces configured with
> different IP addresses. When a client open a Telnet session with one of
> the IP addresses, I need to identify  , to which IP address , the client
> is 'telneting' .  Based on the IP address, i need to run some login
> scripts.

> Is the any command available for this ? Or can you give some pointers ,
> to achieve it through C ?

> Thanks ,
> Karthikeyan S

get lsof from ftp://vic.cc.purdue.edu/pub/tools/unix/lsof.

On HP-UX it would work this way - I don't know how Solaris ps works -

      #!/usr/bin/ksh

      pid=$PPID
      while [[ $pid -gt 1 ]]
         do
         ps -fp $pid | { read waste; read u p ppid rest; }
         [[ $rest = *telnetd* ]] && break
         pid=$ppid
         done

      [[ $pid -eq 1 ]] && { print -u2 "No telnet session found"; exit 1; }

      lsof -an -p$pid -iTCP -d0 -Fn | { read waste; IFS='>:' read w w IP w; }

      print "IP=$IP"

--
Dan Mercer

Opinions expressed herein are my own and may not represent those of my employer.

 
 
 

1. Why I am getting two IP addresses when I connect to my work through VPN

Guys:

I have laptop at home, connect to my home router using WLAN, I do get
IP address from my router 192.168.0.2, I used to connect to my work
using VPN, when I do "ipconfig" I can see two IP address, one for
local LAN and other for VPN, why two IP addresses?.

Also when I work using VPN, I can't go to any of the web sites, like
www.yahoo.com, when I disconnect VPN, everything is OK, what was the
reason?.

Thanks.

2. MORE slack7/glibc troubles

3. From which IP address I am connected

4. Non-destructive Repartitioning an ext2 filesystem

5. Identifying user's remote IP address at login?

6. IRC = learning?

7. API for identifying the DHCP server's IP address.

8. Working on mail server - can anyone give some tips.

9. I am getting a few error lines on boot up that I can't identify.

10. Getting connected socket's ip address

11. Route by IP address over tun0 - 'ip rule add from a.b.c.d'

12. IP Masq'd Workstation to connect to IP Masq'd Workstation