Can one ping a NIC by MAC

You might have better luck using the tool arping instead. The tool ping works at the layer 3 level of the OSI model, whereas arping works at layer 2.

You still need to know the IP of the system however with this tool. There are 2 versions of it, the standard one included with most Unixes (Alexey Kuznetsov's) is the version that can only deal with IP addresses. The other version (Thomas Habets') supposedly can query using MAC addresses.

$ sudo arping 192.168.1.1 -c 1
ARPING 192.168.1.1 from 192.168.1.218 eth0
Unicast reply from 192.168.1.1 [00:90:7F:85:BE:9A]  1.216ms
Sent 1 probes (1 broadcast(s))
Received 1 response(s)

arping works similarly to ping except instead of sending ICMP packets, it sends ARP packets.

Getting a system's IP using just the MAC

Here are a couple of methods for doing the reverse lookup of MAC to IP.

  1. nmap

    $ nmap -sP 192.168.1.0/24
    

    Then look in your arp cache for the corresponding machine arp -an.

  2. fping

    $ fping -a -g 192.168.1.0/24 -c 1
    

    Then look in your arp cache, same as above.

  3. ping

    $ ping -b -c1 192.168.1.255
    

    Then look in your arp cache, same as above.

  4. nbtscan (windows only hosts)

    $ nbtscan 192.168.1.0/24
    
    Doing NBT name scan for addresses from 192.168.1.0/24
    
    IP address       NetBIOS Name     Server    User             MAC address      
    ------------------------------------------------------------------------------
    192.168.1.0 Sendto failed: Permission denied
    192.168.1.4      MACH1            <server>  <unknown>        00-0b-12-60-21-dd
    192.168.1.5      MACH2            <server>  <unknown>        00-1b-a0-3d-e7-be
    192.168.1.6      MACH3            <server>  <unknown>        00-21-9b-12-b6-a7
    

You cannot ping a normal NIC because NIC alone does not send any replies.

Only a running computer is able send replies

Normal network interface cards do not send any replies by themselves. They always need a running software on the computer to do so.

When the CPU of the computer is powered down then there is no running software which would send a reply to a ping.

Wake-on-LAN is unidirectional

Wake-on-LAN allows the computer to let just the NIC be partially powered on to receive Ethernet frames and look for the magic wake-up sequence in them but the NIC will still not send any reply. Wake-on-LAN is strictly unidirectional. There are no responses sent.

Exceptions

There are certain special NICs which could send replies by themselves like for example ones implementing a complete TCP handshake offload.


The ether-wake command will work by mac address, so surely you (a) won't need an IP address and (b) can send the command without harm (if it's already awake, waking it will have no impact?)

You can see the list of your existing arp cache by using arp -an and grepping for your MAC to get the IP of the target host. However, because arp is a cache, it may have been "timed out" of the cache (and still be 'awake'). You then may have to use a brute force method to find it's IP, such as:

 sudo nmap -sP 192.168.2.0/24 | less  

(and then look for 00:0c:0d:ef:02:03) - provided firewalls and other such things don't get in the way!