< TIL: Reverse ARP
A day or two ago someone dropped off a brand new Zebra ZD620 label printer on my desk and said:
"Just plug it up to the network and search for it. Otherwise, you can install the Zebra app and use it to find the printer."
This was for a project I've been working on recently to integrate a custom bar code scanning and printing solution.
I hate installing software! Especially when it's not absolutely required to proceed to my goal. In this case, you can access and administer this Zebra printer through its built-in web management interface. So, installing software just to find the printer seemed a waste.
But, just plugging a network device into a network that you don't administer and "searching for it" is not very trivial either. How do you find one random device among hundreds of devices with no access to your network's DHCP server, switches or router?
Here's how! And the only thing you need is the MAC address of the device you want to find:
Step 1: ping your broadcast domain
The key is to force your computer to learn about everything on its broadcast domain like this:
$ ping -b 192.168.0.255
Press CTRL-c to stop the ping after a few seconds.
Step 2: check your device's arp table for records that match
Next, check your arp table and look for the MAC address you're searching for:
$ arp -a
You'll see a list of all of the IP-to-MAC address records that your device discovered when it ping'ed the broadcast domain in step 1.
? (192.168.3.170) at 04:18:d6:50:35:7e [ether] on ens160 ? (192.168.3.174) at 04:18:d6:50:35:55 [ether] on ens160 ? (192.168.3.8) at 00:50:56:a2:d9:c2 [ether] on ens160 ? (192.168.3.139) at f0:9f:c2:2f:78:18 [ether] on ens160 ? (192.168.3.152) at 00:07:4d:8d:29:67 [ether] on ens160 ? (192.168.3.52) at 00:50:56:b0:4e:56 [ether] on ens160
Hopefully your target MAC address will appear in this list. If so, you've also got the IP address of the device.
Now, I could point my browser to the newly-discovered IP address of the printer and move forward with my project!
I like this solution because:
- its a whole 2 steps long
- it requires no special tools
Of course, there are limits. For one thing, your computer must be on the same broadcast domain as the device you're looking for.