Wednesday, April 15, 2009

Wake-On-Lan

I have a little development server for a website project i am working on. It is running in my home which is also the host of a SVN server and acts as a test server. My friend who is also working on the project needs access to the server every now and then but mostly the server just sits there idle. So in an effort for conservation(save the planet!, save me money!), I figured I could implement a wake-on-lan solution.

Great. So I check to make sure that my card supports wake-on-lan
:~$ sudo ethtool eth0
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: 1
Transceiver: internal
Auto-negotiation: on
Supports Wake-on: pumbg
Wake-on: d
Current message level: 0x00000001 (1)
Link detected: y

Yes it does, but it's disabled. No problem.

~$ sudo ethtool -s eth0 wol g
(later on i had to add this command to the /etc/rc.local file because it gets reset back to disabled).

And then I modify port forwarding on the router.


Using the neat tool WOL- Magic Packet Sender, I set the hostname, the mask to Internet and the MAC address and send the packet of the magii.

It works!

Well so i thought. It turns out that the next day my friend tells me that it doesnt work for him. When I try I find out the same.

why?

I found that its not working because when the server goes down the ARP cache(mapping of ip to MAC address) will expire after a short time and so the router won't know where to send the packet. Theres 2 solutions to this.

1) Have the router forward the packet to the broadcast address.
2) Set a static arp address



I tried the first but apparently LinkSys routers don't support sending to the broadcast address. Instead it just drops the packet on the floor. I haven't found a way to do the second yet.