What's new

Wake On Lan Per HTTP/HTTPS ( Script )

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

Hi guys, Im having trouble with this script.

I have a HP Proliant that wakes from hibernation (Linux mint 13) fine when using the WOL on the tools page.

Ive setup the jffs and scripts as per this guide but still, the machine will not wake when I, for instance, try to play on my PC some music (with WMP12) which is located on the Proliant.

Any ideas?

EDIT: One thing I have noticed, is that the logfile is nowhere to be seen at the location in the wake.sh. Do we need to create the file first?
 
Last edited:
Hi guys, Im having trouble with this script.

I have a HP Proliant that wakes from hibernation (Linux mint 13) fine when using the WOL on the tools page.

Ive setup the jffs and scripts as per this guide but still, the machine will not wake when I, for instance, try to play on my PC some music (with WMP12) which is located on the Proliant.

Any ideas?

EDIT: One thing I have noticed, is that the logfile is nowhere to be seen at the location in the wake.sh. Do we need to create the file first?


Did you reboot the router ?
Its important to reboot the router after you setup the script.
Please give me some details on wich firmware are you and, are the ports forwarded to your server ?
Else it will not work anyway because the router drops the packets.
Did you double check everything because there is not much that would prevent your pc to wake up with this script.
Does your server support wake on lan ? and can you wake it with other tools
 
Thanks for quick reply, so I havnt got any specific ports forwarded for just WOL yet, as I thought it didnt matter in this instance? Maybe I read the previous thread wrong :S

I have some ports forwarded for different things, which other ports need forwarding to the server?

Yeah it does wake from hibernate when I use merlins tool built in to the firmware.

Firmware 220.18b

When entering the MAC address on the script, we include the colons, right?
 
Last edited:
Thanks for quick reply, so I havnt got any specific ports forwarded for just WOL yet, as I thought it didnt matter in this instance? Maybe I read the previous thread wrong :S

I have some ports forwarded for different things, which other ports need forwarding to the server?

Yeah it does wake from hibernate when I use merlins tool built in to the firmware.

Firmware 220.18b

When entering the MAC address on the script, we include the colons, right?

For a server i gues you need to open
HTTP - TCP 80
HTTPS - TCP 443
that would be the basic ports for internet traffic.

This script is for people that want to wake up the computer when someone on the internet browses to their website.
The script you are using wakes up the server on any port that will be accesd.

I will explain a little bit, i hope you dont mind my bad english i will try my best.
Your router is 24/7 connected to the internet and is listning for incoming traffic to your server.
To forward ports so you can acces the server from outside you need a static ip adress that is deliverd by your router ( but you have to set that up yourself )
So if someone browses to http://yourserver.com/ he is actualy trying to acces port 80.
Your router will see that someone is accesing your router at port 80 and will forward it to your server if you did proper portforwarding on the router.
( Note in firewall settings you have to set logged packets to ACCEPT )
The script will monitor the logs and if the script sees in the logs anyone who wants to acces your webserver it will send a wake on lan packet to the MAC adress you provided yourself in the script on the IP that you also manualy enterd.
As for waking up your pc with mediacenter or something i dont know if that is possible because it doesnt use a port forward.
The script is only listning on port forwards.

On my windows server i use something called lights out, it will wake my server when i start a pc or i try to listen to some music and will shut it down whenever i am not using it.
Maybe for your distro there is an alternative to.

So if you want to see if your script is working properly do the following

- Turn of your server
- try to acces your server with your web browser http://yourserver.com
- If it boots then your script is working as intended and for what is was designd
 
When entering the MAC address on the script, we include the colons, right?
Yes in the format like 00:00:00:00
As for the ip you use dots 192.168.1.1

EXAMPLES

And no it doesnt matter because it is an internal broadcast you dont have to forward the wake on lan ports
 
I see, now that you explained it, I was able to wake the server using a WOL Wan/lan tool for android, which externally tried to wake the PC through port 9 which I forwarded. The script picked that up and the server started! :)

I dont need to access anything on the server via 80 or 443 so will leave them closed. I dont host any websites :)

Now I wonder if there is such a tool that allows waking from hibernate from internal PC's trying to access my server, considering that it really is just a file store and downloader.

Im using Linux Mint 13 on the server. There is bound to be something out there :)
 
Well it is possible but its kind of a hassle if you dont host any websites you could also search for the option ''WAKE ON PATTERN MATCH'' this wakes up the pc whenever you are trying to acces it no matter what.
But that would mean that every time you trie to acces your pc or your mediacenter will try to update its library it would wake your server.
And believe me you dont want your server to shutdown and wake up 20 times a day.
It will wreck your disk for sure and i know because it happend to me a couple of times with new disks.
And i dont know wich hardware you run but its a given fact that a computer in hybernation will consume power also.
So it doesnt really matter if it is idling or it is in hybernation.

I use this script to wake up my pc from a complete shutdown.

I you want to try wake on pattern match in windows its at the ehternet adapter properties dialog > power managment.
On linux i do not know actually, but be carefull if you turn it on be sure to check your server if its not constantly booting and shutting down.

Do you use your webserver as a data storage ?
 
Note that port 443 is used by AiCloud. You cannot forward port 443 while AiCloud is enabled.
 
Strange situation i use aicloud and my webserver i acces ai cloud on 8082 and my webserver on 443.
Whats the difrence ?

8082 is the regular access, while 443 is the SSL secured access. I wouldn't use port 8082 when outside of your LAN if I were you, cause otherwise all the login credentials you enter in AiCloud will be sent in clear text. Not just your main router login, but also any SMB login you send while browsing your shares.
 
8082 is the regular access, while 443 is the SSL secured access. I wouldn't use port 8082 when outside of your LAN if I were you, cause otherwise all the login credentials you enter in AiCloud will be sent in clear text. Not just your main router login, but also any SMB login you send while browsing your shares.

Bohh what a mess i cant believe asus did something that stupid ! According to my android phone the app for ai uses 8082 standard !
It will not be possible to change these port either will it ?
Damn i really like the ai cloud but if this is the case then i will shut it down

Thanks for the warning merlin
 
fritsp did you figure out what needed to be added to the script in order to add in specific ports to the target IP aswell?
 
fritsp did you figure out what needed to be added to the script in order to add in specific ports to the target IP aswell?

#!/bin/sh

INTERVAL=5
NUMP=3
OLD=""
TARGET=PUT YOUR INTERNAL IP ADRESS HERE!
PORT=SPECIFY YOUR PORT HERE!
IFACE=br0
MAC=PUT YOUR MAC ADRESS HERE!
WOL=/usr/bin/ether-wake
LOGFILE="/var/log/ether-wake.log"

while sleep $INTERVAL;do
NEW=`dmesg | awk '/ACCEPT/ && /DST='"$TARGET"'/ && /DPT='"$PORT"'/ {print }' | tail -1`
SRC=`echo $NEW | awk -F'[=| ]' '{print $8}'`
DPORT=`echo $NEW | awk -F'[=| ]' '{print $27}'`
PROTO=`echo $NEW | awk -F'[=| ]' '{print $23}'`

if [ "$NEW" != "" -a "$NEW" != "$OLD" ]; then
if ! ping -qc $NUMP $TARGET >/dev/null; then
# echo "NOWAKE $TARGET was accessed by $SRC, port $DPORT, protocol $PROTO and is already alive at" `date`>> $LOGFILE
# else
echo "WAKE $TARGET requested by $SRC, port $DPORT, protocol $PROTO at" `date`>> $LOGFILE
$WOL -i $IFACE $MAC
sleep 5
fi
OLD=$NEW
fi
done


This script is for specifying one port
 
Thanks fritsp!

Can we specify more than one port using that script?

I wanted to do that but no one seems to know how to separate the ports, i asked in a couple of forums.
I really don't know much about scripting this script isn't mine either i just adjusted it to my needs.

I will look again for the solution to specify more ports but i cant promise anything.

It should be a simple argument in the script but i am still a amateur so.
 
Is it correct that the script only works for requests to TARGET coming in from the firewall (i.e., outside the LAN)? I'm trying to wake my NAS when I'm on the WiFi network (i.e., on the LAN), but it doesn't seem to work.

I've searched my log for the TARGET device with an IP of 192.168.80.241, but I don't see it showing up.

I confirm that I can wake the TARGET manually using the router WOL page, and I don't see any errors--I even inserted a few logger commands in the code at various "break-points" and it doesn't seem to ever satisfy the outer "if" statement.

Please let me know what I'm missing. I'm only able to decipher part of the script as I'm just a beginner scripter, haha. Thanks!
 

Similar threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!

Staff online

Top