Is there any such thing as a MAC based ping? Ping is an ICMP protocol
and surely requires an IP address? Hence the "Duh!", as that part of my
response didn't apply to the question the OP asked, get the IP from the
MAC.
There is no purely link-layer ping, but i was thinking about trickery.
I don't think you could use the target's MAC address, a broadcast should
got to each machine. I have never looked at a broadcast packet to see
what MAC address is used in the Ethernet frame (not even sure how to),
maybe the MAC for the default route?
If you're making a real broadcast, it uses the ethernet broadcast address
(FF:FF:FF:FF:FF:FF).
My idea was to send a very special packet, which had the IP broadcast
address in the IP destination address field, but the target machine's MAC
address in the ethernet address field. You'd have to use a super-special
raw socket, a SOCK_PACKET, or direct access to the ethernet driver to do
this. But once you had, ethernet would deliver the packet to the target
machine, and only that machine, and then its IP layer would, hopefully,
interpret it as a packet it should process. It might notice that the MAC
and IP addresses didn't match, and discard it as suspicious, i don't know.
I was then worrying about how you'd get a response from the target that
would put its addresses into your ARP cache (involving a second bit of
trickery at the ARP level), but ...
I've just tried a broadcast ping. I didn't receive any replies, but the
ARP table was populated by every pingable host.
.... in that case, a simple ping should do it. And, indeed, a broadcast
ping would be a crude but effective alternative - as long as you're on the
same ethernet segment (or 'broadcast domain' in a switched ethernet) as
the target.
tom