What is it?
Wake On LAN is a mature technology for switching on computers over a network or remotely.
Why would I want it?
Perhaps you are a techy such as myself and you want to be able to switch customers computers on and work on them remotely (saves having to tell people to leave machines on if you are working after hours).
I also use it to switch on my Ubuntu machine upstairs when I am downstairs (saves me or my better half having to wait for boot or to get a file to or from the machine without physically going up there).
Is it easy to do?
Yes when you know how ;)
Before I go any further I will mention a caveat. Almost all of the WOL howto’s out there mention using a “magic packet” packet to wake the machine. Unfortunately I found out after much head banging and googling “magic packet” doesn’t work over wireless networks, apparently because wireless frames screw the magic packet up so that the wakee doesn’t recognise it any more.
So if you want to use WOL by sending the wake up through a wireless network your options are limited and it depends on the network card you have. At least 2 of the cards I have support a variety of WOL options “pumbg” and the other one only supports “pg”.
- P stands for PHY activity
- U stands for Unicast activity
- M stands for Multicast activity
- B stands for Broadcast activity
- G stands for Magic Packet activity
Firstly I tried phy activity that had the unfortunate effect of starting the machine every few seconds. Then I graduated to broadcast which started the machine periodically (my thick wireless router is sending out broadcasts every hour or so). Eventually I settled on unicast here is how to get it working.
Begin by telling the NIC to use unicast wake up:-
ethtool -s eth0 wol u
You can confirm the command was successful by typing “ethtool eth0” and checking the output. It should be similar to the following:-
Settings for eth0: Supported ports: [ TP MII ] Supported link modes: 10baseT/Half 10baseT/Full 100baseT/Half 100baseT/Full Supports auto-negotiation: Yes Advertised link modes: 10baseT/Half 10baseT/Full 100baseT/Half 100baseT/Full Advertised auto-negotiation: Yes Speed: 100Mb/s Duplex: Full Port: MII PHYAD: 32 Transceiver: internal Auto-negotiation: on Supports Wake-on: pumbg Wake-on: u Current message level: 0x00000007 (7) Link detected: yes
Then make a note of the target machines MAC address either by using ifconfig or looking at the arp cache “arp -n”.
Now you can shut down the target machine to test. Once the machine is off you could just type “ping 192.168.0.1“, where “192.168.0.1” is the IP address of your target machine. That will probably be enough to wake the machine as the MAC address will still probably be associated with the correct IP address in the ARP cache. The only complication comes when the target machine has been switched off for some time. Presumably the MAC to IP association will be removed from the arp cache as a stale entry at some point. Then the sending machine won’t know which MAC address to send the ping to!
We can simulate this by manually deleting the entry in the arp cache and then adding it back in as if the entry never existed. Type “arp -d 192.168.0.1” again where “192.168.0.1” is the IP address of the target machine. Then type “arp -n” to confirm the association has been deleted. Output should be similar to following:-
Address HWtype HWaddress Flags Mask Iface 192.168.0.1 (incomplete) wlan0
We can now add the entry back in:-
arp -s 192.168.0.1 00:16:17:65:B4:62
and check the entry was successful “arp -n”:-
Address HWtype HWaddress Flags Mask Iface 192.168.0.1 ether 00:16:17:65:B4:62 CM wlan0
Finally you can type “ping 192.168.0.1” and make Frankensteinian euphemisms like “it lives” or “it breathes”!