Wake-on-LAN on Linux with a Linksys WRT54g

My D-Link router died and I bought a Linksys WRT54g thinking I could put Linux on it. Unfortunately, I should have checked a little more before I bought it because I got a v5, which has half of the RAM and flash memory and is not compatible with most 3rd party firmwares. I also found out that I could not forward packets to the broadcast address, which is exactly what I needed to do to get Wake-on-LAN working.

I use a web based Wake on LAN utility to wake up my computer. Since a computer that isn’t powered on does not have an IP address, it listens for a “magic packet”. A magic packet is data sent over the network to every computer that has the MAC address of the computer you want to turn on. I needed to forward the magic packet to the broadcast address, which on my home LAN was UDP port 9 on 192.168.1.255. However, the Linksys WRT54g will not allow you to forward a port to xxx.xxx.xxx.255, so I needed to find another way. After doing some research, I found out that I could change the subnet from 255.255.255.0 to 255.255.255.128, so the broadcast address would then be xxx.xxx.xxx.127, which could then be forwarded in the Linksys WRT54g.

Update: Aaditya Bhatia also suggested turning off Javascript temporarily to disable the error check. This works well, but please use caution as entering something less than 0 or greater than 255 could possibly kill the router permanently.

Next, I needed to turn on Wake on LAN support in Linux. I did an “apt-get install ethtool” and ran “ethtool eth0″ in the console. It read “Wake-on: d”, showing that wake on LAN was disabled. I ran “ethtool -s eth0 wol g” which turned it on. However, it would only work one time and then I would have to run “ethtool -s eth0 wol g” again. I found that if you edit /etc/network/interfaces and add “up ethtool -s eth0 wol g” under “iface eth0″, it would run every time the interface was started.

Thanks to this article for the ethtool info: http://www.debian-administration.org/articles/122

and thanks to this site for the subnet calculator: http://www.subnet-calculator.com/

WoL on WRT54G

I tried your suggested method, but the router still does not seem to forward the magic packet to the whole net. I tried from a pc in the LAN to send a magic packet on the public address of the router, port 9, but nothing happened. Instead, when I sent the same packet on the broadcast addess 192.168.1.127, it worked... Do you think the router could be so "smart" to understand that a packet forwarded to 192.168.1.127 would be broadcast to all local network, and thus refuse to forward it (for some security reasons)? =(

the new firmware from Linksys

the new firmware from Linksys are not capable of triggering broadcast to local network