Plex, WOL, DD-wrt, port range??



Hi all!
Im trying to enable WOL on plex-traffic using a DD-WRT router but things are not working for me...

Ive been following numerous tutorials and guides so im not sure exactly what ive done and havent done, but the situation is as follows:

I upgraded DD-WRT to latest stable version for my device (asus rt-n13u b1); V3.0-r31221 std, configured USB storage, installed optware and enabled logging, set log level to HIGH and enabled logging for both accepted, dropped and rejected.

The server is a windows 10 box, with WOL functioning (tested and confirmed working) and latest version of Plex Media Center.

The clients for this test is my laptop (macbook, 10.10.5 (yosemite) using the web app) and my android phone (v6.0), using the plex media player app.

The script im using is included at the bottom of this post.

Now, i do get entries popping up on the URL: (WOL-script log) and i do get sporadic entries there, but not every time i try to access my server.

I digged a bit and came across the system log on the URL: and from what i gathered, it appears as if plex uses a number of ports, not only the default 32400.
My system logs mention 32412, 32414 and probably a few others that i havent found yet..

So my big question is; what ports are actually in use when the client (android app and/or web app) tries to connect to the server using default port?

The almost as big question would be; how can one edit the shellscript (found below) to incorporate more than one PORT?
I imagine that something like "if=PORT>PORTMIN && <PORTMAX" instead of "PORT=".
However, i am no programmer nor have i any skills with scripts so any and all tips would be greatly appreciated!


Enable JFFS2 and place script in /jffs/ then run on startup in web interface.

You can check the log from

MAC=12:34:56:78:90 # i have used correct mac, just anonymizing my script..

echo "" > $LOGFILE
echo "["date"] AUTO WOL Script started.

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 "


echo "WAKE $SRC causes wake on lan at" date "


echo "

sleep 1






I have been trying to accomplish the same thing. My (Linux) Plex server did wake when the app contacted the server on port 32400 but the server would go back to sleep while a movie was streaming. My understanding on how to fix this is to put the Plex server on it's own VLAN and detect any packets destined for the server IP address to send a WOL signal. I have not yet tried this out as I am still learning how to set up the VLAN on my DD-WRT router.


Stu, regarding your issue that your server disconnects during playback; ive heard that this only happens if youre streaming the media directly (no on-the-fly re-encoding), so a simple work-around to solve your issue would be to force re-encoding for all media.
Im not sure how to, or if its even possible, but there´s a bone for you to chew on, at least.. :)


I have pinpointed the problem even further.
It turns out that plex uses a number of ports to communicate with the server, not only the one defined in settings (32400 as default).

The other ports are:
32410, 32412, 32413, 32414 (port range for GDM network discovery)

There are a few other ports used for other types of streaming, but the ones above would be good enough for most users i think..

So the shell-script that checks the network logs needs to be modified to allow for a list of ports, instead of just a single port.

So is there anybody out there who can do shell-script fluidly enough to make these changes?
..And of course, willing to help.. :)