I will address and describe methods I use to get information from equipment connected on wifi network, no doubt the ping
is an alternative, but if the device has some firewall or anti-virus blocking packages ICMP
, you will never get back, the same happens for any type of Scan that tries to scan your network, besides being slow has great chances of having some equipment browsing on your network in which the scan can not catch.
The safest way to bring correct information is to go straight to the source (i.e., your router), you can enable queries via SNMP in your router/access point, I believe it is very rare a network equipment that does not have this option nowadays, this way you can consult any information distributed by the equipment, such as bandwidth consumption, CPU usage, memory used and it is very likely that some OID
(is the identifier, a number that collects information for a certain need) return a list of Macs addresses of the devices connected to it.
Here is a real example of using:
snmpwalk -v2c -c senhaSNMPAQUI 192.168.1.214 enterprises.171.11.37.4.4.5.2.1.2.1
SNMPv2-SMI::enterprises.171.11.37.4.4.5.2.1.2.1.1 = Hex-STRING: 2X V6 98 XX XX XX
SNMPv2-SMI::enterprises.171.11.37.4.4.5.2.1.2.1.2 = Hex-STRING: A1 52 66 XX XX XX
SNMPv2-SMI::enterprises.171.11.37.4.4.5.2.1.2.1.3 = Hex-STRING: 51 SF 6D XX XX XX
Of course I picked up the information in this example using a Unix client called snmpwalk
, the parameters will always be versão
of the SNMP to comunity
(type a password for access), the address IP
of your router and the OID
that brings the information you need, each equipment has specific Oids and most of the time you will need to take this information in documentation provided by the manufacturer, for my Dlink here the OID
that brings the information of equipment connected to it is the enterprises.171.11.37.4.4.5.2.1.2.1
, OK you can do the same using java libs to do snmp query, I believe you will find several, one of them and with example is SNMP4J. Then you ask me in your example have three connected equipments, as I know the IP
theirs ?
One of the ways is to send one broadcast
network and catch the return of the table arp
arp -a
? (192.168.1.11) at A1 52 66 XX XX XX on eth0 expires in 931 seconds [ethernet]
? (192.168.1.52) at 2X V6 98 XX XX XX on eth0 expires in 1169 seconds [ethernet]
? (192.168.1.17) at 51 SF 6D XX XX XX on eth0 expires in 650 seconds [ethernet]
My equipment is china and has no SNMP or no SNMP OID’s that bring the information I need and now?
Enable on your router some remote access method (ssh, telnet), connect to the device and find some command inside it that takes the information you need
Another real example:
telnet 192.168.2.1
Trying 192.168.2.1...
Connected to 192.168.2.1.
Escape character is '^]'.
login: usuariodorouter
Password: ******
WAP-> get clientinfo
Client1--time:1424
Client1--ssid: primary SSID
Client1--mac:CW:45:67:XX:XX:XX
Client1--auth:OPEN
Client1--rssi:11
Client1--mode:11n
Client1--psmode:0
Client1--rx_bytes:234239
Client1--tx_bytes:285309
In this example a telnet connection was made on the router and I ran the command get clientinfo
, again you will need to query some doc from the manufacturer to know which command returns what you need, in java there are also telnet client libs that make this connection and iteration for sending commands, all you have to do is gather the data...
Lucas, I don’t know exactly how to do (so I can’t help) because I’ve never dealt with local DNS lookup. I found a question in the EN OS that can help you start sketching the solution: http://stackoverflow.com/questions/13198669/any-way-to-discover-android-devices-on-your-network. The question is very broad. I suggest starting to implement and any doubt carry out a new question with the code you have already made.
– Wakim
This week I need to do something similar, I thank Luiz for the edition, I was almost creating a question here.
– Renan Gomes
@re22 I found the question cool and worthy of editing. I’m glad it will possibly help more people. :)
– Luiz Vieira