But for some unknown reason this script is not working in my tp-link archer c9 router. And also enabling JFFS2 can brick my router.
https://svn.dd-wrt.com//ticket/6037
But following script seems to be working.
Code:
#!/bin/sh
TARGET=<ip of plex server>
MAC=<mac of plex server>
PORTS="(32400)"
INTERVAL=2
NUMP=1
OLD_LC=`dmesg | wc -l | awk '{print $1}'`
while sleep $INTERVAL
do
LC=`dmesg | wc -l | awk '{print $1}'`
if [ "$LC" -ne "$OLD_LC" ]; then
LINE=`dmesg | tail -1`
SRC=`echo $LINE | awk '{print $8}' | sed -e "s/SRC=//g"`
if [ "$SRC" != "" ]; then
# Found a matching line. Try to ping the server
RET=`ping -c $NUMP -W 1 $TARGET 2> /dev/null | awk '/packets received/ {print $4}'`
if [ "$RET" -ne "$NUMP" ]; then
# Guess it's sleeping. Send WoL.
echo "[`date -Iseconds`] $SRC causes WOL. Line was $LINE" >> /var/log/wol
/usr/sbin/wol -i <boardcast ip (typically 192.168.1.255)> -p 7 $MAC
sleep 10
fi
fi
fi
OLD_LC=`dmesg | wc -l | awk '{print $1}'`
done
So can any one help me complete this script? In current state this script keeps waking my server.
Also I don't know how to add that iptables script mentioned at the end of that post.
My firmware version is DD-WRT v3.0-r40559 std (08/06/19)
Joined: 18 Mar 2014 Posts: 12915 Location: Netherlands
Posted: Sun Jan 02, 2022 12:08 Post subject:
Unfortunately you were posting in the wrong forum.
Furthermore the build you are using is not only old and unsupported it is also a bad build, consider upgrading.
After upgrade reset to defaults and put settings in manually, never restore from a backup to a different build.
Please read the forum guidelines with helpful pointers about how to research your router, where and what firmware to download, where and how to post and many other helpful tips:
https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=324087
Unfortunately you were posting in the wrong forum.
Furthermore the build you are using is not only old and unsupported it is also a bad build, consider upgrading.
After upgrade reset to defaults and put settings in manually, never restore from a backup to a different build.
Please read the forum guidelines with helpful pointers about how to research your router, where and what firmware to download, where and how to post and many other helpful tips:
https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=324087
I will transfer this thread to the appropriate forum
Thanks. Sorry for posting without reading forum guide lines.
I checked for upgrades and there seems to be only one more update released after the version I'm currently using for my router.
So you think I may have messed up my previous upgrade making those script not working?
Seems to me that script could use a little cleanup. It could be simplified. It also places a burden on the router to parse the dmesg log every 2 seconds. Not the kind of thing I like to see.
Anyway, as I see it, the part I believe the OP has missed is the following.
Notice you're instructed to add two firewall rules to force the port forward to be logged. One if the requests comes from inside the LAN, the other if the request comes from the internet. This is unlike the original script which told you to turn ALL logging on. And if all other logging is OFF, and you find a log entry in dmesg, then has to be the one you triggered (w/ the port you specified) in the firewall rules.