Wake On WAN From More Than A Computer Using Script.

daviddrf

Occasional Visitor
Hello all again. I've been testing the script commented here and it works perfect, thank you!:
https://github.com/RMerl/asuswrt-merlin/wiki/WOL-Script-Wake-Up-Your-Webserver-On-Internet-Traffic
This script allows me to avoid entering on the router's web to wake any computer.
I tested it with one of my two PCs, and it worked flawlessly. I've been using the search engine of this forum but I haven't been able to find the answer to the following two questions:

1) How should I do for being able to wake more than a computer using the script named before?
2) Is there any way to Wake On WAN in AsusWRT-Merlin like it is done in DD-WRT without scripts, with telnet commands making a permanent ARP table entry like "arp -i br0 -s 192.168.x.x XX:XX:XX:XX:XX:XX"? (like this: http://www.ptere.com/wol/)

Thanks in advance.
 

Steffe

Regular Contributor
1) Both at the same time or independently? First option; add another "$WOL -i $IFACE $MAC"... Second option requires that you run two scripts(or one if you rewrite the code) which monitors different ports for traffic.

2) You can only make Wake on Wan if you add entries. These will reset upon router reboot. I've made a script to add them post boot. So, i guess that is a no to your answer..
 

faria

Senior Member
I just duplicate the script from the wiki ( one entry per device) into a single script.
 

daviddrf

Occasional Visitor
Hello again. First of all thank you Steffe and faria por your answers and support.
1) Both at the same time or independently? First option; add another "$WOL -i $IFACE $MAC"... Second option requires that you run two scripts(or one if you rewrite the code) which monitors different ports for traffic.

2) You can only make Wake on Wan if you add entries. These will reset upon router reboot. I've made a script to add them post boot. So, i guess that is a no to your answer..
1) I would like to to it independently. How could I do that in only one script rewriting the code? I already did the port forwarding/redirection for each port for either PC.

2) A script to autoadd the static ARP table's entries post boot would be great. Is this not the same than the script said before?
I just duplicate the script from the wiki ( one entry per device) into a single script.
How would "look" this final single script?

Thank you again Steffe and faria for your support.
 

faria

Senior Member
As Such:
Code:
#!/bin/sh
/usr/bin/logger -t START_$(basename $0) "started [[email protected]]"
INTERVAL=5
NUMP=3
OLD=""
TARGET=192.168.1.236 #SKYNET
PORT=3390
IFACE=br0
MAC=XX:04:A6:4A:C0:XX
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

#######################################################
INTERVAL=5
NUMP=3
OLD=""
TARGET=192.168.1.200# NAS
PORT=
IFACE=br0
MAC=XX:11:32:2D:13:XX
WOL=/usr/bin/ether-wake
LOGFILE="/var/log/wakenas.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
####################################################
INTERVAL=5
NUMP=3
OLD=""
TARGET=192.168.1.111 #Patricia pc
PORT=3388
IFACE=br0
MAC=XX:46:5D:89:EC:XX
WOL=/usr/bin/ether-wake
LOGFILE="/var/log/ether-wakejunkyard.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
/usr/bin/logger -t STOP_$(basename $0) "return code $?"
 

daviddrf

Occasional Visitor
As Such:
Code:
#!/bin/sh
/usr/bin/logger -t START_$(basename $0) "started [[email protected]]"
INTERVAL=5
NUMP=3
OLD=""
TARGET=192.168.1.236 #SKYNET
PORT=3390
IFACE=br0
MAC=XX:04:A6:4A:C0:XX
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

#######################################################
INTERVAL=5
NUMP=3
OLD=""
TARGET=192.168.1.200# NAS
PORT=
IFACE=br0
MAC=XX:11:32:2D:13:XX
WOL=/usr/bin/ether-wake
LOGFILE="/var/log/wakenas.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
####################################################
INTERVAL=5
NUMP=3
OLD=""
TARGET=192.168.1.111 #Patricia pc
PORT=3388
IFACE=br0
MAC=XX:46:5D:89:EC:XX
WOL=/usr/bin/ether-wake
LOGFILE="/var/log/ether-wakejunkyard.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
/usr/bin/logger -t STOP_$(basename $0) "return code $?"
Thank you a lot faria for sharing this script. With this script it would be possible to wake 3 different computers, right?
 

faria

Senior Member
Thank you a lot faria for sharing this script. With this script it would be possible to wake 3 different computers, right?
Yes, been using it for over a year.
You can add more devices if you wish.
Remember :
You also need to add the mac a dresses to the wake on lan router page.
You also need to foward the ports used in the script.
If you use a vpn client you also need to foward the ports using a selective routing script.
And finally, you need to configure your devices wake on lan features on,bios,network cards and operation system if needed.
Windows 8 and 10 can be triky because of fast startup,you may have to desable it in windows.
Once properly configured you can launch remote desktop from another device once you press connect it will start up the pc you trying to reach and login. Please note that the delay starting up the pc may timeout the remote desktop session in that case press connect once again.
Example:
You know that you pc takes 60 seconds to boot from cold,
When you press connect in the temote desktop app it will send a magic packet and will wake the pc, but because the boot process Is quite long the remote desktop app will time out.
By waiting 1 minute after first ping you are making sure the pc is up and running, now pressing connect in the remote desktop app it will log you in.
 

daviddrf

Occasional Visitor
Yes, been using it for over a year.
You can add more devices if you wish.
Remember :
You also need to add the mac a dresses to the wake on lan router page.
You also need to foward the ports used in the script.
If you use a vpn client you also need to foward the ports using a selective routing script.
And finally, you need to configure your devices wake on lan features on,bios,network cards and operation system if needed.
Windows 8 and 10 can be triky because of fast startup,you may have to desable it in windows.
Once properly configured you can launch remote desktop from another device once you press connect it will start up the pc you trying to reach and login. Please note that the delay starting up the pc may timeout the remote desktop session in that case press connect once again.
Example:
You know that you pc takes 60 seconds to boot from cold,
When you press connect in the temote desktop app it will send a magic packet and will wake the pc, but because the boot process Is quite long the remote desktop app will time out.
By waiting 1 minute after first ping you are making sure the pc is up and running, now pressing connect in the remote desktop app it will log you in.
Yes, I sucessfully tested it today, thank you again faria.
I noticed that sometimes there's a delay (some seconds) between the momment when I send the magic packet and the PC wakes on. Is this something related to the script?
 

faria

Senior Member
Yes, I sucessfully tested it today, thank you again faria.
I noticed that sometimes there's a delay (some seconds) between the momment when I send the magic packet and the PC wakes on. Is this something related to the script?
It is and it's not,I asume that the script itself I not the problem but the time the router takes to check the script,find the target device and then send the packet to wake it.
It's quite allot going on in the background to wake a device in this maner.
Perhaps someone with more knowledge about it can chime in.
 

daviddrf

Occasional Visitor
It is and it's not,I asume that the script itself I not the problem but the time the router takes to check the script,find the target device and then send the packet to wake it.
It's quite allot going on in the background to wake a device in this maner.
Perhaps someone with more knowledge about it can chime in.
I understand. It's OK, thank you again faria for your support and happy new year ;) .
 

daviddrf

Occasional Visitor
Hello. First of all I want to say sorry for reviving an almost nine month old post.
I want only to say that I've found a better way to enable Wake On WAN (LAN and outside from LAN) on my RT-AC68U with AsusWRT-Merlin firmware than the proposed by faria. I had tested this way on my older routers with DD-WRT, and in all of them worked like a charm. This way consists in enabling a PERMANENT static entry (which stays and remains in the ARP table even after rebooting the router) connecting the private LAN IP to the ethernet card MAC address you want to wake up.
The faria way was cool, the problem is I wasn't able to wake up any device after some hours. I was able to wake up in the first hours since last reboot, but later was imposible. Then I have been looking for this forum and I found this very useful post: http://www.snbforums.com/threads/create-static-arp-using-services-start-to-survive-reboot.34100/
This was EXACTLY was I was looking for. With this way you apply that permanent static entry in the ARP table in the "services-start" file which exists after enabling the JFFS partition and its configs and scripts under the "Administration tab". You can even access it with WINSCP like it is shown in this tutorial and manually editing the "services-start" file:
https://github.com/RMerl/asuswrt-merlin/wiki/WOL-Script-Wake-Up-Your-Webserver-On-Internet-Traffic
Although is much faster "writing" it on the router by telnet or SSH access like on the first post is said:

Code:
cat << EOF > /jffs/scripts/services-start
#!/bin/sh
/sbin/arp -s 192.168.1.2 AB:CD:EF:1G:2F:3G
EOF
Then...

Code:
chmod 777 /jffs/scripts/services-start
...and finally...

Code:
reboot
After rebooting the router I've tested it on it and I am able to quickly wake any device forever, a lot of hours after the router was rebooted. In addition the faria way has a little bit delay between you hit the WAKE UP button and the computer wakes UP. This other way is INMEDIATE, there's no delay.
Thank you all and goodbye ;).
 
Last edited:

chiquito

Occasional Visitor
I have done everything poneis in the scripts but in the last operation where it says go and accept packages firewall and router to reboot I run out of internet pages do not open
 

MKANET

Occasional Visitor
David, thanks so much for your post. Just over 40 minutes ago I realized my Asus RT-AC5300's stock firmware didn't have a way to save or run the ARP -s command I needed for WOL (after my router reboots). I was able to find your post, which showed EXACTLY how to do this step-by-step; even, with very little Linux experience.

Hello. First of all I want to say sorry for reviving an almost nine month old post.
I want only to say that I've found a better way to enable Wake On WAN (LAN and outside from LAN) on my RT-AC68U with AsusWRT-Merlin firmware than the proposed by faria. I had tested this way on my older routers with DD-WRT, and in all of them worked like a charm. This way consists in enabling a PERMANENT static entry (which stays and remains in the ARP table even after rebooting the router) connecting the private LAN IP to the ethernet card MAC address you want to wake up.
The faria way was cool, the problem is I wasn't able to wake up any device after some hours. I was able to wake up in the first hours since last reboot, but later was imposible. Then I have been looking for this forum and I found this very useful post: http://www.snbforums.com/threads/create-static-arp-using-services-start-to-survive-reboot.34100/
This was EXACTLY was I was looking for. With this way you apply that permanent static entry in the ARP table in the "services-start" file which exists after enabling the JFFS partition and its configs and scripts under the "Administration tab". You can even access it with WINSCP like it is shown in this tutorial and manually editing the "services-start" file:
https://github.com/RMerl/asuswrt-merlin/wiki/WOL-Script-Wake-Up-Your-Webserver-On-Internet-Traffic
Although is much faster "writing" it on the router by telnet or SSH access like on the first post is said:

Code:
cat << EOF > /jffs/scripts/services-start
#!/bin/sh
/sbin/arp -s 192.168.1.2 AB:CD:EF:1G:2F:3G
EOF
Then...

Code:
chmod 777 /jffs/scripts/services-start
...and finally...

Code:
reboot
After rebooting the router I've tested it on it and I am able to quickly wake any device forever, a lot of hours after the router was rebooted. In addition the faria way has a little bit delay between you hit the WAKE UP button and the computer wakes UP. This other way is INMEDIATE, there's no delay.
Thank you all and goodbye ;).[/CODE]
 

elorimer

Very Senior Member
Is there a way this works within the LAN? I.e., if I RDP from one computer to another in the same LAN?
 

faria

Senior Member
Is there a way this works within the LAN? I.e., if I RDP from one computer to another in the same LAN?
Yes , but you will have to use a different port number in the second Pc,
Also once you change the Port number on the second pc you need to forward the port on the router .
And finally once you changed the RDP port on the second pc , you need to create a firewall exception for the new port on the Windows firewall .
 

chiquito

Occasional Visitor
I have an rt-ac88u router with merlin firmware and I often use wake on lan on my pc to control it from outside my network.
The problem is that when the router is reset it loses the entry in the router's arp table, I created the scripts that you put in the forum but it doesn't work for me when I reset the route the ip changes and I have to put the arp data back by hand..
You know why I created the services-start file inside the jffs / scripts / folder, I have given it 0777 permissions and it doesn't work for me, any ideas?
Thank you ..
 

daviddrf

Occasional Visitor
I have an rt-ac88u router with merlin firmware and I often use wake on lan on my pc to control it from outside my network.
The problem is that when the router is reset it loses the entry in the router's arp table, I created the scripts that you put in the forum but it doesn't work for me when I reset the route the ip changes and I have to put the arp data back by hand..
You know why I created the services-start file inside the jffs / scripts / folder, I have given it 0777 permissions and it doesn't work for me, any ideas?
Thank you ..
Hello. I'm sure that this happens because you make some mistake in the procedure which is described in this post.
 

chiquito

Occasional Visitor
I have done it as described in the jjfs post format then I paste the lines in the services-start file I give permissions 0777 and reboot and I still change the ip


Enviado desde mi iPhone utilizando Tapatalk
 

Sign Up For SNBForums Daily Digest

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