Hack 26 Quickly Poll Wireless Clients with pingA quick and dirty method for determining who is on your local subnet.This is a simple, quick hack, but useful in many circumstances. Suppose you are associated with a wireless network, and are curious about who else is also using the network. You could fire up a network sniffer (like Ethereal [Hack #38] or tcpdump [Hack #37]), or manually scan for associated clients (using nmap[Hack #40]), although that might be construed as antisocial. You're not so much interested in what people are doing, just how many people are online.It is simple to find clients on your local network using the ubiquitous ping utility. Simply ping the broadcast address of your network, and see who responds. You can find the broadcast address by running ifconfig like so: rob@florian:~$ ifconfig eth0 There it is, the Bcast address. This is the broadcast address for your local subnet, which every machine is listening to. In Mac OS X and BSD, it is simply listed as the broadcast address: rob@caligula:~$ ifconfig en1 Most (but not all) machines will respond to a ping sent to this address. But simply running ping won't always leave enough time for the clients to respond between echo requests. Run ping with a long wait time (say, 60 seconds) between requests, and be sure to send at least one ping: rob@florian:~$ ping -c3 -i60 10.15.6.255 After duplicates (those suffixed with DUP!) stop arriving, feel free to hit Control-C to kill the running ping, or wait 60 seconds for another try. This gives you a quick, rough idea of how many machines are connected to the local subnet.Note that not all machines answer to broadcast ping requests, and some block ICMP traffic (ping's protocol) altogether. Still, in terms of ease, speed, and ubiquity, you can't beat the results of the broadcast ping.If you are curious about what kinds of wireless cards people are using, you might try looking up their serial numbers online [Hack #27]. |