2016-08-06

Sending WakeOnLan (WOL) from Linux (KUbuntu)


In order to have the Synology NAS already been running when I boot up my Ubuntu (KUbuntu) computer, I make my Ubuntu send a WOL packet to the NAS when booting with etherwake.

Here is the command used in the script below (Replace the exemplary MAC address 00:11:22:33:44:55 below by the MAC address of the device you want to be woken up.)
root@Ubuntu:~# etherwake -i eth1 00:11:22:33:44:55


root@Ubuntu:/etc/init.d# cat sendWOLtoNAS
#! /bin/sh
### BEGIN INIT INFO
# Provides: sendWOLtoNAS
# Required-Start:    
# Required-Stop:     
# Default-Start: 2
# Default-Stop:      
# Short-Description: Sends Wake On Lan (WOL) packet to the Synology NAS
# Description: Is used in order to make sure that the NAS will also be started when this computer is starting
### END INIT INFO

MYSELF="/etc/init.d/sendWOLtoNAS"

logger "${MYSELF} Start"
etherwake -i eth1 00:11:22:33:44:55
logger "${MYSELF} WOL sent, sleeping 10s"
sleep 10
logger "${MYSELF} Done"

Making the script be run on startup of Ubuntu
root@Ubuntu:/etc/init.d# update-rc.d sendWOLtoNAS start 20 2 .
 Adding system startup for /etc/init.d/sendWOLtoNAS ...
  /etc/rc2.d/S20sendWOLtoNAS -> ../init.d/sendWOLtoNAS

If you want to undo it:
root@Ubuntu:/etc/init.d# update-rc.d -f sendWOLtoNAS remove 20 2 .
 Removing any system startup links for /etc/init.d/sendWOLtoNAS ...
  /etc/rc2.d/S20sendWOLtoNAS


Tags: ubuntu, Linux, Boot, WOL, Startup, Publish
May 30, 2016 at 09:22PM

No comments :

Post a Comment