User avatar
fbutler
Posts: 302
Joined: Thu Mar 15, 2012 4:09 pm
Location: Surrey, England

Wake on LAN Relay Daemon

Wed Jun 06, 2012 7:12 am

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.

spikyface
Posts: 1
Joined: Sat Sep 22, 2012 12:45 pm

Re: Wake on LAN Relay Daemon

Sat Sep 22, 2012 12:57 pm

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.)

Piminiuser
Posts: 73
Joined: Wed May 30, 2012 1:15 pm

Re: Wake on LAN Relay Daemon

Sat Dec 08, 2012 7:42 pm

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.
Last edited by Piminiuser on Sun Mar 31, 2013 8:04 am, edited 1 time in total.

User avatar
malakai
Posts: 1382
Joined: Sat Sep 15, 2012 10:35 am
Contact: Website

Re: Wake on LAN Relay Daemon

Sat Dec 08, 2012 8:24 pm

@fbutler This is fantastic do you mind if I add this to my How To section.
http://www.raspians.com - always looking for content feel free to ask to have it posted. Or sign up and message me to become a contributor to the site. Raspians is not affiliated with the Raspberry Pi Foundation. (RPi's + You = Raspians)

sk8r721
Posts: 7
Joined: Wed May 08, 2013 5:52 am

Re: Wake on LAN Relay Daemon

Wed May 08, 2013 5:54 am

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?
Last edited by sk8r721 on Wed May 08, 2013 5:59 pm, edited 1 time in total.

SirLagz
Posts: 1705
Joined: Mon Feb 20, 2012 8:53 am
Location: Perth, Australia
Contact: Website

Re: Wake on LAN Relay Daemon

Wed May 08, 2013 7:46 am

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
My Blog - http://www.sirlagz.net
Visit my blog for Tips, Tricks, Guides and More !
WiFi Issues ? Have a look at this post ! http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=44044

sk8r721
Posts: 7
Joined: Wed May 08, 2013 5:52 am

Re: Wake on LAN Relay Daemon

Wed May 08, 2013 5:37 pm

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!

xan105
Posts: 1
Joined: Wed May 08, 2013 9:13 pm

Re: Wake on LAN Relay Daemon

Wed May 08, 2013 9:16 pm

Works perfectly !
Thanks for you great work.
Instructions was pretty straightforward ;) greatjob

User avatar
fbutler
Posts: 302
Joined: Thu Mar 15, 2012 4:09 pm
Location: Surrey, England

Re: Wake on LAN Relay Daemon

Fri May 10, 2013 9:20 am

xan105 wrote:Works perfectly !
Thanks for you great work.
Instructions was pretty straightforward ;) greatjob
Good to know :-)

sk8r721
Posts: 7
Joined: Wed May 08, 2013 5:52 am

Re: Wake on LAN Relay Daemon

Fri May 10, 2013 3:43 pm

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...

User avatar
fbutler
Posts: 302
Joined: Thu Mar 15, 2012 4:09 pm
Location: Surrey, England

Re: Wake on LAN Relay Daemon

Fri May 10, 2013 3:54 pm

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?

pjaeckel
Posts: 1
Joined: Sun Sep 01, 2013 3:33 pm

Re: Wake on LAN Relay Daemon

Sun Sep 01, 2013 4:08 pm

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 179 times
for anyone else who may have difficulty getting it to work and potentially benefiting from the extra diagnostics.

Regards,
pj

User avatar
fbutler
Posts: 302
Joined: Thu Mar 15, 2012 4:09 pm
Location: Surrey, England

Re: Wake on LAN Relay Daemon

Sun Sep 01, 2013 4:55 pm

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.

Return to “Networking and servers”