AsusWRT WakeOnLan a PC based on incoming port request

This script will let you Wake On Lan a PC on your lan based on a port set. If an incoming request is made on one of the assigned ports, the script will wake the target machine.

You might need to disable NAT hardware acceleration. This script requires the folowing utilities that can be found in optware/entware. If you don't know what that is look it up.

  • tcpdump
  • timeout (part of coreutils pack)

Go into your /jffs/scripts folder and create a new file "" and paste the following. The run chmod +x

#!/bin/sh #How often to run this script in seconds INTERVAL=2 #set your target machine IP and MAC here TARGET= MAC=XX:XX:XX:XX:XX:XX #ether-wake location WOL=/usr/sbin/ether-wake #set your log name and location here LOGFILE="/jffs/wol.log" #set your ports list here, default list includes remote desktop and FTP ports PORTS='dst port 3389 or dst port 20 or dst port 21' #Do not edit below this line while sleep $INTERVAL;do test=`timeout 1 tcpdump -i any 'dst host '$TARGET' and ('$PORTS') and tcp[tcpflags] & (tcp-syn) != 0 and tcp[tcpflags] & (tcp-ack) == 0' -nn -t -s 0 -c 1 -q` 2> /dev/null sleep $INTERVAL if [ "${#test}" -ne "0" ]; then echo $(date +"%Y-%m-%d %H:%M:%S") "$test" >> $LOGFILE $WOL -i br0 $MAC fi done

You have to include in your services-start file. If you don't have that, go into your /jffs/scripts folder and create a new file "services-start" and paste the following. The run chmod +x services-start
Edit services-start and paste the following:

#!/bin/sh #script for sending WOL packets when traffic to specified ip's sh /jffs/scripts/

Reboot your router and you're ready.
The script has been tested on AsusWRT-Merlin but it should work on most WRT based routers


Customizing your terminal looks in AsusWRT-Merlin

The stock terminal is a bit too black and white for my taste. Luckily you can change lots of stuff by using one of Merlin's override options.

  • Go into the /jffs/configs/ folder
  • Create a new file named profile.add
  • You can paste here whatever options you like. For example I wanted filesizes in Mb,Gb etc and colors so i wrote
alias ls='ls -ahl --color=auto'

If you use Midnight Commander but the graphics and keymappings are all wrong, also include the following lines in profile.add

export TERMINFO=/opt/share/terminfo alias mc='mc -ac'

The next time you login to your console, the new options will apply
To read more about the override options take a look at this link:



Send me a Message:

Created by BLACKTIE.CO