Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

I have an NIC card on a Debian machine somewhere. The machine is turned off, but I need to know whether the NIC card is turned on so that I can send a wake-on-lan magic packet later (from another Debian machine) to wake it up. I have the MAC address of the card. Is there any way I can ping the ethernet card by MAC to see whether it is on?

I tried creating an ARP entry:

arp -s 192.168.2.2 00-0c-0d-ef-02-03
ping 192.168.2.2

That didn't work, since the NIC card does not have this ip address. So the NIC card would receive the ping request but would not reply to it. Is there any way around this?

I am using the etherwake package to send a wake-on-lan message.

share|improve this question

migrated from stackoverflow.com Aug 9 '13 at 18:44

This question came from our site for professional and enthusiast programmers.

3 Answers 3

up vote 11 down vote accepted

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
    
share|improve this answer
2  
arping can take a MAC address as a parameter: arping -c 5 38:e7:d8:63:5e:a6 –  niervol Aug 9 '13 at 21:03
    
@MichaelMrozek - I did it after someone had basically posted my answer as a comment and hadn't read what I said about 2 versions of arping. The other answer looks to have been deleted so thanks for taking out my bold frustrations. –  slm Aug 10 '13 at 18:10
    
Thanks for the help. Marking this as resolved. We couldn't find a WOL option in the BIOS setup. This is my guess: The BIOS did not have WOL turned on, but the NIC did. So the NIC was waking up on the first WOL packet, and was sending a message to the BIOS. But since it was not turned on in the BIOS, the BIOS did not do anything. From this moment onwards, the NIC responded to ping since it was awake, but the machine was not. So quick question: Is it possible for the BIOS to have WOL turned off and the NIC to have it turned on at the same time? –  Alastor Moody Aug 14 '13 at 21:06
1  
@AlastorMoody - I would say that you're probably allowed to turn BIOS WOL off w/ NIC's WOL turned on. However if you BIOS doesn't support WOL, then I don't think you'll be able to make use of it even if the NIC does. See the wikipedia article on WOL: en.wikipedia.org/wiki/Wake-on-LAN. Says the same thing as I in the "troubleshooting magic packets" section. –  slm Aug 14 '13 at 23:12
    
@niervol: arping to a MAC address: Yes, there are two implementations of arping 1. from Linux iputils 2. arping by Thomas Habets. --- Only the 2. implementation can ping a MAC address but such a ping is very tricky: The pinged machine still has to have TCP/IP configured (at least an IP address) and it must be able to respond to a ping to a broadcast IP address. –  pabouk Aug 19 at 13:02

The ether-wake command will work by mac address, so surely you a) wont 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 bruce 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!

share|improve this answer
    
I don't want to wake the machine up right now. But I want to ensure that the NIC can receive my messages so that when I go offsite and turn on the machine via a WOL packet, I know it is going to turn on. That's why I want to ping by IP or MAC and not wake it up. –  Alastor Moody Aug 9 '13 at 19:51
1  
Sleeping machines will not respond to ping. If the machine is turned on and you ping by IP (and the host reponds), it will put an entry in the arp cache. If the entry in there matches the MAC address of the host, there is a reasonable chance it will work (baring other network firewalls, routers and other physical issues that may cause the ether-wake not to reach it). I would actually get access to another host onsite, put the target machine to sleep and attempt the ether-wake. By the nature of how WOL works, the request will have to be sent on the same subnet as the host anyway –  Drav Sloan Aug 9 '13 at 20:06
2  
@DravSloan the Bonjour Proxy available on e.g. Apples Time Capsule is a quite ingenious way to handle this proble. The machine sleeps but the router responds for it, and only wakes it up when the proxy can't handle it anymore. –  Thorbjørn Ravn Andersen Aug 9 '13 at 23:07
    
Thanks for the useful insights everyone. –  Alastor Moody Aug 14 '13 at 21:03

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.

share|improve this answer
    
+1 — this is the only answer that truly addresses the OP's question. "Wake-on-LAN is unidirectional". –  Celada Aug 19 at 11:46

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.