getting entire host name or ip address

getting entire host name or ip address

Post by John Mark Emer » Fri, 18 Sep 1998 04:00:00



Does anyone know how to go about getting the full host name or IP
address of any given person logging into or logged into a linux
machine?  If you do a who or a finger I just don't get the output that I
need.  Who and finger cut the host name off short if it's over 16
characters long.

If I could get my hands on the source code for who or finger, maybe I
could modify them to output what I want.  Or...is there any other
current command?

If you look in the /var/adm/messages file, you can get the full ip
address of everyone who logged into the machine, but I'd rather do it
another way.

Anyone...anyone??

John Emery
Sue Mills, Inc.
415-864-1899X146

 
 
 

getting entire host name or ip address

Post by felicity+s.. » Fri, 18 Sep 1998 04:00:00



Quote:> Does anyone know how to go about getting the full host name or IP
> address of any given person logging into or logged into a linux
> machine?

well, for currently logged in people, do a 'who' (not a 'w') ...  for people
who were logged in, do 'last -a' ...

--
To reply via mail, please remove the obvious from the email address.

 
 
 

getting entire host name or ip address

Post by John Mark Emer » Fri, 18 Sep 1998 04:00:00


You didn't include my entire origional message for some reason.  Of course I
tried who and finger and w, all of those parse the end of the host name output
if it's over 16 characters.  I wondered if anyone knew of a way to get the
entire, FULL hostname?

The output of finger for example is:

        wwu05   william j wu            p1  4:17   Sep 17 09:37
(32.atl-dal900.po)
        eeng02    edward p. eng          p0     20   Sep 17 11:06
(6.irvtnt.pool.en)
        xzhao01  xiu juan zhao            p2     19   Sep 17 11:07
(13.irvtnt.pool.en)

The output of who is similar.  The last column on the right is the host name of
the remote computer.  It's cut off though!  For example, the full address of the
first line is "32.atl-dal900.pool.eni.net", next one should be
"6.irvnt.pool.eni.net", and so on.

I need the full host name to configure remote printers dynamically with a
script.  Thanks for responding.

John Emery
Sue Mills, Inc.
415-864-1899X146



> > Does anyone know how to go about getting the full host name or IP
> > address of any given person logging into or logged into a linux
> > machine?

> well, for currently logged in people, do a 'who' (not a 'w') ...  for people
> who were logged in, do 'last -a' ...

> --
> To reply via mail, please remove the obvious from the email address.

 
 
 

getting entire host name or ip address

Post by david kahan » Sat, 19 Sep 1998 04:00:00



> Does anyone know how to go about getting the full host name or IP
> address of any given person logging into or logged into a linux
> machine?  If you do a who or a finger I just don't get the output that I
> need.  Who and finger cut the host name off short if it's over 16
> characters long.

* little problem ... I don't know a solution yet, but this has
annoyed  me too. If you use netstat instead there is also a cutoff.
On my system I got:

netstat:

Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 sdn-ar-002nydpar:telnet bnlnth.phy.bnl.gov:1248
ESTABLISHED
tcp        0      0 sdn-ar-002nydparP2:1752 charts2.quot:supfiledbg
ESTABLISHED
tcp       53      0 sdn-ar-002nydparP2:1747 birch.prod.itd.ear:nntp
CLOSE_WAIT
tcp        1      0 sdn-ar-002nydparP2:1730 204.209.212.113:www
CLOSE_WAIT
tcp        0      0 sdn-ar-002nydparP2:1662 bnlnth.phy.bnl.g:telnet
ESTABLISHED
tcp       53      0 sdn-ar-002nydparP2:1646 fir.prod.itd.earth:nntp
CLOSE_WAIT
udp        0      0 localhost:ntp           *:*

Sorry for the format, but you can see there is still a cutoff
after 16 chars. This can't be too hard to fix if you had the
source. I'll keep poking around, and let you know if
anything turns up.

The source for netstat is in the file net-tools-1.45.tar.
You can also see whether you are dealing with a
telnet session, and the source may help you
find out how the symbolic hostnames are
generated.

-- dave k.

 
 
 

getting entire host name or ip address

Post by david kahan » Mon, 21 Sep 1998 04:00:00



> Does anyone know how to go about getting the full host name or IP
> address of any given person logging into or logged into a linux
> machine?  If you do a who or a finger I just don't get the output that I
> need.  Who and finger cut the host name off short if it's over 16
> characters long.

> If I could get my hands on the source code for who or finger, maybe I
> could modify them to output what I want.  Or...is there any other
> current command?

> If you look in the /var/adm/messages file, you can get the full ip
> address of everyone who logged into the machine, but I'd rather do it
> another way.

> Anyone...anyone??

> John Emery
> Sue Mills, Inc.
> 415-864-1899X146

This is a very ugly hack, but I checked the source of netstat,
and it is not too hard to get the full address out. The cutoff
is hard coded into the function tcp_do_one, in netstat.c:

static void tcp_do_one(int lnr, const char *line)
{

       ...

    /*    if ((strlen(local_addr) + strlen(buffer)) > 22)
      local_addr[22-strlen(buffer)] = '\0'; */

    if ((strlen(local_addr) + strlen(buffer)) > 44)
      local_addr[44-strlen(buffer)] = '\0';

    strcat(local_addr, ":");
    strcat(local_addr, buffer);
    sprintf(buffer,  "%s", get_sname(htons(rem_port), "tcp",
    flag_not));

    /*    if ((strlen(rem_addr) + strlen(buffer)) > 22)
      rem_addr[22-strlen(buffer)] = '\0'; */

    if ((strlen(rem_addr) + strlen(buffer)) > 44)
      rem_addr[44-strlen(buffer)] = '\0';

  ...

Quote:}

the commented lines are the original, with a cutoff of 22
chars. the uncommented ones were changed by me to
allow twice the length for the output. the key function
that resolves the name is get_sname, as you can see.
its probably not too hard to make this much nicer, maybe
add an option to netstat to get just the complete local and
remote addresses of tcp and udp connections, and format
them more reasonably.

but it will take me a little while to do that. i used net-tools-1.45.
here is the output of the modified netstat on my system:

Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 sdn-ar-002nydparP266.dialsprint.net:2412
crow.a001.sprintmail.com:pop3 TIME_WAIT
tcp       53      0 sdn-ar-002nydparP266.dialsprint.net:2410
holly.prod.itd.earthlink.net:nntp CLOSE_W
tcp       53      0 sdn-ar-002nydparP266.dialsprint.net:2404
fir.prod.itd.earthlink.net:nntp CLOSE_WAI
tcp        1      0 sdn-ar-002nydparP266.dialsprint.net:2336
www-me5.netscape.com:www CLOSE_WAIT
tcp        1      0 sdn-ar-002nydparP266.dialsprint.net:2335
www-me5.netscape.com:www CLOSE_WAIT
udp        0      0 localhost:ntp           *:*

Cheers,

-dave k.

 
 
 

1. Can't ping the host name or host IP address from host.

Hello there,
I have the unusual problem of not being able to ping the machines host name
or host IP address from the host.
I've checkout the network settings and I can't seem to find any problems.  I
am able to ping & telnet to the machine
from the network.  Seems quite strange.

Any help would be really appreciated.

thanks,

Owen.

Here is output from ifconfig


lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Bcast:127.255.255.255  Mask:255.0.0.0
          BROADCAST LOOPBACK  MTU:3584  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0

eth0      Link encap:Ethernet  HWaddr 00:60:08:83:28:08
          inet addr:10.0.0.100  Bcast:10.0.0.255  Mask:255.0.0.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:41411 errors:0 dropped:0 overruns:0 frame:0
          TX packets:259 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0
          Interrupt:3 Base address:0x300



PING penguin (10.0.0.100): 56 data bytes
ping: sendto: Network is unreachable
ping: wrote penguin 64 chars, ret=-1

--- penguin ping statistics ---
3 packets transmitted, 0 packets received, 100% packet loss


PING 10.0.0.100 (10.0.0.100): 56 data bytes
ping: sendto: Network is unreachable
ping: wrote 10.0.0.100 64 chars, ret=-1

--- 10.0.0.100 ping statistics ---
3 packets transmitted, 0 packets received, 100% packet loss

2. Solaris 7 Practice Exams, will sell for $40

3. how to change domain name, host name, ip address

4. Ummm...Need a little help

5. IP Masquerading - Can't use Host names only IP address

6. Mosaic 2.4.2 (TueV) + term on Slackware 2.0.1

7. getting a host ip name

8. Super "BSD" Computer

9. rh6.2, changing IP address gets destination host unreachable

10. Hosting multiple named domains with one IP address?

11. Unable to find IP address / host name lookup failure with DHCP (dhclient)

12. IP Address & Host Name

13. Changing a host's name/ip address