Page 1 of 1

Wake on LAN Relay Daemon

Posted: Wed Jun 06, 2012 7:12 am
by fbutler
A lot of routers prevent broadcast packets being forwarded onto the local LAN for security reasons which prevents the Wake on LAN protocol being used to wake computers on the local LAN from the Internet directly.

As the Pi is a low power consumption device it makes it an ideal candidate to use as a Wake On LAN relay device to waken other computers on the local LAN from the Internet.

I've wriiten a small 'C' program to act as a Wake on LAN relay daemon on the Pi to enable it to provide Wake on LAN functionality by sending a Wake on LAN packet to the Pi with the MAC address of the target computer on the local LAN. The Pi verifies the WoL packet and the MAC address contained within it and then relays the packet out on the broadcast IP address of the local LAN. Details of the daemon, including the source files, can be found here:

http://www.trans-omni.co.uk/pi/wol-relayd/

It's the first Daemon program that I've written, and the first 'C' program that I've written in a while, so all constructive criticism on how to improve it would be gratefully received. The daemon was written and tested using the Debian distribution.

I've provided some basic documentation on the daemon at the link above. I intend to write some more detailed documentation on it based on feedback received.

Re: Wake on LAN Relay Daemon

Posted: Sat Sep 22, 2012 12:57 pm
by spikyface
Hi

I'm running XBMC on my Raspberry Pi but would also like to install this wake on LAN relay too

The problem is when I try to do any of the steps from 7 onwards it doesn't work:
7) Type 'make' to compile the program.

I'm guessing this is because the XBMC image doesn't have the necessary compiler tools to start the daemon but the Raspbian Wheezy image does, since steps 7 and onwards work fine on this image

Is there a way of running this wake on lan relay in XBMC?

I know a bit about Linux but have not used it for programming before today. I've done some programming in Windows before (web development, batch and powershell scripts, java applet programming, C#, etc.)

Re: Wake on LAN Relay Daemon

Posted: Sat Dec 08, 2012 7:42 pm
by Piminiuser
Hi,

I found your tutorial with google. I copy'd your tutorial for 99% And added 1 rule.

http://raspberrypihelp.net/tutorials/9-wake-on-lan

Thnx for YOUR great work.

Re: Wake on LAN Relay Daemon

Posted: Sat Dec 08, 2012 8:24 pm
by malakai
@fbutler This is fantastic do you mind if I add this to my How To section.

Re: Wake on LAN Relay Daemon

Posted: Wed May 08, 2013 5:54 am
by sk8r721
When I get to the make install step I get an error.

Code: Select all

sudo cp wol-relayd /usr/local/bin/wol-relayd
make: sudo: Command not found
make: *** [install] Error 127
am I missing something here?

Re: Wake on LAN Relay Daemon

Posted: Wed May 08, 2013 7:46 am
by SirLagz
You're missing the sudo program.
I'm guessing you'd be logged in as root, or be able to su to root.
su to root first before running it

Re: Wake on LAN Relay Daemon

Posted: Wed May 08, 2013 5:37 pm
by sk8r721
SirLagz wrote:You're missing the sudo program.
I'm guessing you'd be logged in as root, or be able to su to root.
su to root first before running it
I've tried logging in directly as root, su to root, and running it without root privileges. They all give me the same error.

Edit:: Nevermind, ran apt-get install sudo and the make install command works now. But now I've got another problem, when I try to start the daemon I receive this:

Code: Select all

[FAIL] Starting wol-relayd: wol-relayd failed!

Re: Wake on LAN Relay Daemon

Posted: Wed May 08, 2013 9:16 pm
by xan105
Works perfectly !
Thanks for you great work.
Instructions was pretty straightforward ;) greatjob

Re: Wake on LAN Relay Daemon

Posted: Fri May 10, 2013 9:20 am
by fbutler
xan105 wrote:Works perfectly !
Thanks for you great work.
Instructions was pretty straightforward ;) greatjob
Good to know :-)

Re: Wake on LAN Relay Daemon

Posted: Fri May 10, 2013 3:43 pm
by sk8r721
sk8r721 wrote: Nevermind, ran apt-get install sudo and the make install command works now. But now I've got another problem, when I try to start the daemon I receive this:

Code: Select all

[FAIL] Starting wol-relayd: wol-relayd failed!
Somehow, even with the error when starting the service, everything is working...

Re: Wake on LAN Relay Daemon

Posted: Fri May 10, 2013 3:54 pm
by fbutler
sk8r721 wrote:
sk8r721 wrote: Nevermind, ran apt-get install sudo and the make install command works now. But now I've got another problem, when I try to start the daemon I receive this:

Code: Select all

[FAIL] Starting wol-relayd: wol-relayd failed!
Somehow, even with the error when starting the service, everything is working...
It's a long time since I wrote the code, but did you check that the daemon wasn't already running before trying to start it?

Re: Wake on LAN Relay Daemon

Posted: Sun Sep 01, 2013 4:08 pm
by pjaeckel
Hi - great little utility, thank you fbutler!

It did not work at first for me. It turned out that the android WoL utility I am using sends 108 bytes but wol-relayd.c checks for the byte count to be exactly 102 bytes. I modified it to demand at least 102 bytes, and ignore any excess. To track down the problem, I first added some more diagnostic logging which also goes to syslog. I also added the option to specify a different relay port in the sense of

Usage: wol-relayd port broadcast_ip config_filename [ relayport ]

Wikipedia says that WoL is usually sent to UDP port 7 or 9. Since I used the free utility WakeOnLanMonitor for testing which requires to know the LAN port to listen to, I needed to know which port the packets are relayed to. I found 0x2fff in the code, which translates to 12287. I found some mentioning on the web stating "The standard WOL port these days is Port 9. The old standard is port 12287.", so I made the default relay port to be 9.

I attach a patch
wol-relayd.c.patch.7z
(1.88 KiB) Downloaded 194 times
for anyone else who may have difficulty getting it to work and potentially benefiting from the extra diagnostics.

Regards,
pj

Re: Wake on LAN Relay Daemon

Posted: Sun Sep 01, 2013 4:55 pm
by fbutler
pjaeckel wrote:Hi - great little utility, thank you fbutler!
It did not work at first for me. It turned out that the android WoL utility I am using sends 108 bytes but wol-relayd.c checks for the byte count to be exactly 102 bytes. I modified it to demand at least 102 bytes, and ignore any excess. pj
I'm glad you got it working. Looking at : http://wiki.wireshark.org/WakeOnLAN it looks like the extra bytes are for an optional password. I must have missed that when I wrote it. Thanks for adding the extra diagnostics. I'll check them out when I get some time.