View computers connected to MBL?


#1

Hi all,

Another (rookie, I’m sure) question: is there any way to view what computers are currently connected to the MBL and/or a given share? I’m trying to troubleshoot some issues, and it would help a great deal if there was some way of viewing, in real time (or, **bleep**, even via log file), what computer/IP is talking to the MBL.

So, any options? :slight_smile:


#2

Does your router keep a connection log?


#3

Yes, but (I think) due to the fact that the device is connected to a Repeater Bridge running DD-WRT (which shows up on my router as an unknown device, despite, obviously, having an IP since I can reach it via web interface) makes the logs utterly useless.


#4

Just log in to shell using putty or any other similar programm and type

netstat

That will show you established connections in real time.


#5

Thank you!


#6

Jazzymood is heading you in the right direction.

To limit the output to YOUR specific question, it’d be:

netstat | grep ESTABLISHED | grep microsoft

Keep in mind, though, that SAMBA is sorta connectionless.   Your PC can be “Connected” to the MBL without actually having an open network port…  Your PC can open the port just long enough to get the info it needs, and then close it.


#7

Netstat shows you open network connections, however NFS can use UDP and is stateless; so netstat won’t help with that.

If you’re already into the MBL via ssh, there are some other commands that are really handy, and give more detail.

I’ll give some detailed examples.  Here I’m just starting an SMB session (Windows networking) from a Linux host. (Mind the line wrap)

mario@stump:/smb$ smbclient //mybooklive/Public -N
Domain=[WORKGROUP] OS=[Unix] Server=[Samba 3.2.5]
smb: \> dir
  . D 0 Mon Apr 25 19:16:34 2011
  .. D 0 Tue Apr 19 10:46:33 2011
  Shared Videos D 0 Tue Apr 19 10:46:33 2011
  Software D 0 Tue Apr 19 10:46:33 2011
  Shared Pictures D 0 Tue Apr 19 10:46:33 2011
  Shared Music D 0 Tue Apr 19 10:46:33 2011
  new D 0 Sun Apr 17 11:00:43 2011

		59108 blocks of size 16777216. 20481 blocks available
smb: \>

On the MBL, you can see these Windows sessions using smbstatus.

MyBookLive:~# smbstatus

Samba version 3.2.5
PID Username Group Machine                        
-------------------------------------------------------------------

Service pid machine Connected at
-------------------------------------------------------
Public 29606 stump Tue Apr 26 13:06:40 2011

No locked files

My Linux box also uses automounted NFS shares from the MBL. You can see these too.

mario@stump:~$ df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda1 304829804 98972352 190494896 35% /
none 896956 268 896688 1% /dev
none 901184 2856 898328 1% /dev/shm
none 901184 380 900804 1% /var/run
none 901184 0 901184 0% /var/lock
none 901184 0 901184 0% /lib/init/rw

mario@stump:~$ showmount -e mybooklive
Export list for mybooklive:
/nfs *
mario@stump:~$ cd /net/mybooklive/nfs/Public
mario@stump:/net/mybooklive/nfs/Public$ df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda1 304829804 98972356 190494892 35% /
none 896956 268 896688 1% /dev
none 901184 2856 898328 1% /dev/shm
none 901184 380 900804 1% /var/run
none 901184 0 901184 0% /var/lock
none 901184 0 901184 0% /lib/init/rw
mybooklive:/nfs 968428672 632867072 335561600 66% /net/mybooklive/nfs
mario@stump:/net/mybooklive/nfs/Public$ ls -l
total 320
drwxrwx--- 8 99 mario 65536 2011-04-17 11:00 new
drwxrwxr-x 2 root mario 65536 2011-04-19 10:46 Shared Music
drwxrwxr-x 2 root mario 65536 2011-04-19 10:46 Shared Pictures
drwxrwxr-x 2 root mario 65536 2011-04-19 10:46 Shared Videos
drwxrwxr-x 2 root mario 65536 2011-04-19 10:46 Software

and over on the MBL, I see this session like this:

MyBookLive:~# showmount -a
All mount points on MyBookLive:
192.168.2.100:/nfs

and finally, the MBL includes a very good utility called lsof, which allows you figure out what Unix process on the MBL is connecting to which network socket.

MyBookLive:~# lsof -i
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
dhclient3 1088 root 4u IPv4 1828 UDP *:bootpc 
upnp_nas_ 1200 root 3u IPv4 2136 TCP *:49153 (LISTEN)
upnp_nas_ 1200 root 4u IPv4 2137 UDP localhost.localdomain:50307 
upnp_nas_ 1200 root 6u IPv4 2139 UDP *:1900 
portmap 1212 daemon 4u IPv4 2195 UDP *:sunrpc 
portmap 1212 daemon 5u IPv4 2197 TCP *:sunrpc (LISTEN)
apache2 1385 root 3u IPv4 2693 TCP *:www (LISTEN)
apache2 1398 www-data 3u IPv4 2693 TCP *:www (LISTEN)
apache2 1399 www-data 3u IPv4 2693 TCP *:www (LISTEN)
apache2 1400 www-data 3u IPv4 2693 TCP *:www (LISTEN)
apache2 1401 www-data 3u IPv4 2693 TCP *:www (LISTEN)
apache2 1402 www-data 3u IPv4 2693 TCP *:www (LISTEN)
apache2 1410 www-data 3u IPv4 2693 TCP *:www (LISTEN)
rpc.statd 1538 root 5u IPv4 3468 UDP *:866 
rpc.statd 1538 root 7u IPv4 3476 UDP *:40594 
rpc.statd 1538 root 8u IPv4 3479 TCP *:42013 (LISTEN)
rpc.mount 1580 root 7u IPv4 3615 UDP *:48893 
rpc.mount 1580 root 8u IPv4 3620 TCP *:43954 (LISTEN)
nmbd 1592 root 7u IPv4 3685 UDP *:netbios-ns 
nmbd 1592 root 8u IPv4 3686 UDP *:netbios-dgm 
nmbd 1592 root 9u IPv4 3690 UDP MyBookLive.stargard.ca:netbios-ns 
nmbd 1592 root 10u IPv4 3691 UDP MyBookLive.stargard.ca:netbios-dgm 
smbd 1594 root 18u IPv6 3727 TCP *:microsoft-ds (LISTEN)
smbd 1594 root 19u IPv6 3729 TCP *:netbios-ssn (LISTEN)
afpd 1631 root 5u IPv4 3791 TCP *:12548 (LISTEN)
afpd 1631 root 6u IPv4 3811 TCP *:afpovertcp (LISTEN)
mDNSRespo 1658 root 3u IPv4 3840 UDP *:41150 
mDNSRespo 1658 root 4u IPv4 3846 UDP *:mdns 
twonkymed 1715 root 2u IPv4 4093 TCP localhost.localdomain:9000 (LISTEN)
twonkymed 1715 root 4u IPv4 4101 TCP MyBookLive.stargard.ca:9000 (LISTEN)
twonkymed 1715 root 5u IPv4 4104 UDP MyBookLive.stargard.ca:1900 
twonkymed 1715 root 6u IPv4 4106 UDP 239.255.255.250:1900 
cvm 1770 root 25u IPv6 781818 UDP *:17694 
cvm 1770 root 26u IPv6 4942 TCP *:1641 (LISTEN)
cvm 1770 root 34u IPv6 5090 TCP *:1910 (LISTEN)
apache2 3755 www-data 3u IPv4 2693 TCP *:www (LISTEN)
apache2 16809 www-data 3u IPv4 2693 TCP *:www (LISTEN)
apache2 16816 www-data 3u IPv4 2693 TCP *:www (LISTEN)
apache2 21932 www-data 3u IPv4 2693 TCP *:www (LISTEN)
sshd 29551 root 3u IPv4 779768 TCP *:ssh (LISTEN)
sshd 29551 root 4u IPv6 779770 TCP *:ssh (LISTEN)
sshd 29645 root 3r IPv4 780229 TCP MyBookLive.stargard.ca:ssh->stump.stargard.ca:59465 (ESTABLISHED)
smbd 29790 root 22u IPv6 781040 TCP MyBookLive.stargard.ca:microsoft-ds->stump.stargard.ca:53728 (ESTABLISHED)

In this last listing, you can see the SSH session from my Linux box into the MBL.

Cheers,

M