At our office we have a netgear router,

I'd like to poll it to see who's in the office (preferably on the command line) because i'm weird like that..

Is their a standard way of doing this? is it possible to do on all routers or does your router need to have an API for this?

I should also mention i'm on a mac

link|improve this question
feedback

1 Answer

up vote 1 down vote accepted

"Standard" would be SNMP MIB entry .1.3.6.1.2.1.4.22 (.iso.org.dod.internet.mgmt.mib-2.ip.ipNetToMediaTable).

$ snmpwalk -v 2c fog.home .1.3.6.1.2.1.4.22
IP-MIB::ipNetToMediaIfIndex.1.192.168.1.94 = INTEGER: 1
...
IP-MIB::ipNetToMediaPhysAddress.1.192.168.1.94 = STRING: 0:13:d4:f4:2b:c4
...
IP-MIB::ipNetToMediaNetAddress.1.192.168.1.94 = IpAddress: 192.168.1.94
...
IP-MIB::ipNetToMediaType.1.192.168.1.94 = INTEGER: dynamic(3)
...

If your router does not support SNMP, you can run arp over SSH or screen-scrap the web interface.

link|improve this answer
Thanks :) Thats probably a much better solution than what i came up with.. Our network is reasonably small (about 10 machines) do you think i'd get away with this instead (just seems a bit simpler)? arp -a | grep 192 | awk '{print $4}' – Daniel Upton Sep 27 '11 at 15:50
If you execute it on the router - yes. On your Mac - no, usually not. – grawity Sep 27 '11 at 16:19
Okay.. what would it normally do on the mac? seems to get everyone in my office when i run it.. (sorry for my network noobness!) – Daniel Upton Sep 27 '11 at 16:22
The ARP cache generally only contains devices you recently communicated with. The exact criteria depends on the network setup. If every machine sends periodic broadcasts - such as for name resolution - their addresses might be cached by your Mac, which would be fine for you. But that's not always the case - larger corporate networks might use only unicast DNS. – grawity Sep 27 '11 at 16:32
Thanks.. looks like a screen scrape.. No SSH or SNMP, drat! – Daniel Upton Sep 27 '11 at 16:59
show 1 more comment
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.