3

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

1 Answer 1

3

"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, your next option would be to connect using SSH or Telnet, run ip neigh or arp -n, then parse the output. (The "expect" tool is useful for automating Telnet logins and subsequent command-line interaction.)

If that isn't available either, you'll have to hack something up to scrape the web interface.

6
  • 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}' Commented Sep 27, 2011 at 15:50
  • If you execute it on the router - yes. On your Mac - no, usually not. Commented Sep 27, 2011 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!) Commented Sep 27, 2011 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. Commented Sep 27, 2011 at 16:32
  • Thanks.. looks like a screen scrape.. No SSH or SNMP, drat! Commented Sep 27, 2011 at 16:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .