auto WOL on port-specific traffic, shellscript help needed

Post new topic   Reply to topic    DD-WRT Forum Index -> Advanced Networking
Author Message
DD-WRT Novice

Joined: 29 Dec 2009
Posts: 12

PostPosted: Thu May 11, 2017 14:40    Post subject: auto WOL on port-specific traffic, shellscript help needed Reply with quote
Hi all!
I hope this landed in the correct category, otherwize i am very sorry for my mistake!

First some details:
dd-wrt router (asus rt-n13u b1), running v3.0-r31221std
Server: Windows 10 pc, running Plex Media Center and has WOL enabled, tested and confirmed working.
Clients: laptop (wlan), android phone (wlan&mobile network).

Im trying to have the router detect plex-traffic to the server and if the server doesnt answer, a WOL packet should be sent.

Ive been following a number of different tutorials to set this up and so far ive enabled logging on the router, level HIGH and for both accept, dropped and rejected.

The page shows all the traffic correctly, but the script log; does not show each plex connect.

Ive been trying to understand why syslog shows the traffic but not WOL log and ive found that plex uses a number of different ports, not just the default one.

i do think i have a "solution", but i lack the skills to implement it..

the wol-script does define PORT= but i think that it shouldnt be a single port, but a number of them.
So instead of "PORT=32400" it should be something like: "PORT=32400,32410,32412,32413,32414,1900" and so on, but i simply do not grasp how to change the script accordingly.

So does anybody have the skills to modify the script for me?
Any new traffic to any of the listed ports should trigger the "ping server, if no reply, send WOL" feature.

the ports i need are 32400(default), 32410, 32412, 32413, 32414(port range for GDM network discovery) and 1900(DLNA).

The script im using is copied from a unknown source (might be here at, might be some other tut, its been to many google searches to be sure..).

#Enable JFFS2 and place script in /jffs/ then run on startup in web interface.
#You can check the log from


echo "<meta http-equiv=\"refresh\" content=\"10\">" > $LOGFILE
echo "["`date`"] AUTO WOL Script started. <br>" >> $LOGFILE

while sleep $INTERVAL;do
NEW=`dmesg | awk '/ACCEPT/ && /DST='"$TARGET"'/ && /DPT='"$PORT"'/ {print }' | tail -1`
SRC=`dmesg | awk -F'[=| ]' '/ACCEPT/ && /DST='"$TARGET"'/ && /DPT='"$PORT"'/ {print $7}' | tail -1`
LINE=`dmesg | awk '/ACCEPT/ && /DST='"$TARGET"'/ && /DPT='"$PORT"'/'`
if [ "$NEW" != "" -a "$NEW" != "$OLD" ]; then                                               
   if ping -qw $PINGTIME $TARGET >/dev/null; then                                                 
      echo "NOWAKE $TARGET was accessed by $SRC and is already alive at" `date` "<br>">> $LOGFILE   
      echo "WAKE $SRC causes wake on lan at" `date` "<br>">> $LOGFILE                         
      $WOL -i $BROADCAST -p $WOLPORT $MAC >> $LOGFILE                                             
      echo "<br>" >> $LOGFILE                                                                 
      sleep 1                                                                                 
DD-WRT Novice

Joined: 24 Jul 2017
Posts: 17

PostPosted: Mon Jul 24, 2017 22:27    Post subject: Reply with quote
Have you had any luck so far?

I want to implement a similar script to wol Plex, but my dd-wrt router is a secondary router. Really hoping to find some info!
Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum Index -> Advanced Networking All times are GMT


Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum