Adding Scripts to Router (WOL)

davo1979

Occasional Visitor
Hello, I am trying to setup WOL to access my unraid server. I am using an app internally to turn the server on and it works perfect so WOL is setup correct and is working however when I try to do this remotely I just can't seem to get it to work. I have tried various instruction and am trying out this method at the moment. The document can be found here:


Is there a way to add this script into my router? I have ssh in but not quite sure where to enter the code. Or if anyone can guide me with a better way I am open to sugestions.

My router is ASUS AC68u running 386.5_2-gnuton0

Thanks.


2022-04-04_09h08_26.png
 

GSpock

Senior Member
... when I try to do this remotely I just can't seem to get it to work ...
have you correctly configured a DDNS on the router in order to make sure you remotely access the correct public IP address .... unless you mean something else by "remotely" ....
 

davo1979

Occasional Visitor
Hi, yes I use my routers Asus ddns address.
 

Attachments

  • BlurAndPixelate_Apr042022_115319.jpg
    BlurAndPixelate_Apr042022_115319.jpg
    36.8 KB · Views: 45
  • BlurAndPixelate_Apr042022_115256.jpg
    BlurAndPixelate_Apr042022_115256.jpg
    36.2 KB · Views: 46
  • Screenshot_20220404-115036_Chrome.jpg
    Screenshot_20220404-115036_Chrome.jpg
    21.4 KB · Views: 45

eibgrad

Part of the Furniture
Your ARP example and port forward don't match. If your local IP network is 10.10.20.0/24, then you set aside an IP solely for this purpose (e.g., 10.10.20.254), which never gets assigned to an actual device, then port forward to that same IP. When you're on the public side of your WAN, you then need to specify the MAC address of the actual target of WOL in order for it to work. When you're on the LAN side, you can use the local IP (e.g., 10.10.20.106) because it can use ARP to determine the MAC address, something it can't do on the internet side of the WAN.

P.S. Don't ever use the x.x.x.255 address for anything. That's the broadcast address, and broadcasts are usually NOT allowed across the firewall. That's why the example solution uses 192.168.1.254, rather than 192.168.1.255.
 

eibgrad

Part of the Furniture
Once it's working, you can make it persistent using an init-start script.

Code:
SCRIPTS_DIR='/jffs/scripts'
SCRIPT="$SCRIPTS_DIR/init-start"

mkdir -p $SCRIPTS_DIR

create_script() {
cat << 'EOF' > $SCRIPT
#!/bin/sh
(
sleep 120
arp -i br0 -s 10.10.20.254 FF:FF:FF:FF:FF:FF
) &
EOF
chmod +x $SCRIPT
}

if [ -f $SCRIPT ]; then
    echo "error: $SCRIPT already exists; requires manual installation"
else
    create_script
    echo 'Done.'
fi
:

Enable JFFS script in Administration > System, then copy/paste the above into terminal window of an SSH connection to the router (which will configure and install the script) and reboot.

Note: The script will NOT overwrite any pre-existing init-start script, including one of its own making. If some other addon is using the init-start script already, you'll need to manually add the script's code to it.
 

davo1979

Occasional Visitor
Wow thank you so much!!! Just remind me what to set the port forwarding to please?

Thanks.
 

davo1979

Occasional Visitor
IIRC, when I was doing this a few years ago, I simply added a port forward from 7799 (external) to UDP 10.10.20.254:9 (internal).
OK so I ran your script and it did what it did, made a file with 10.10.20.254 and ff:ff etc. I port forwarded external port to 3535 internal port to 9 and internal ip to 10.10.20.254 and rebooted the router.

On the app I have I put the routers ddns address xxxxxx.asuscomm.com and set the port to 3535 but still nothing.
 

eibgrad

Part of the Furniture
When you're on the internet side of the WAN, the status check IP/Hostname needs to be that of your router's WAN, NOT the local, internal IP (10.10.20.106).
 

eibgrad

Part of the Furniture
What port do you use (successfully) when you're connected locally? 7? 9? That should be the internal port of the port forward.

P.S. Or maybe the app hides this from you and tries both 7 and 9.
 

eibgrad

Part of the Furniture
Yes 9 is working perfect internal, WOL from that app starts my server up from cold.

Then your port forward should work if the internal ip : port is 10.10.20.254:9. IOW, the app should use 3535 to your external WAN ip and forward UDP to 10.10.20.254:9 to wake the device.
 

davo1979

Occasional Visitor
Then your port forward should work if the internal ip : port is 10.10.20.254:9. IOW, the app should use 3535 to your external WAN ip and forward UDP to 10.10.20.254:9 to wake the device.
I know right... scratching my head.
 

Similar threads

Latest threads

Sign Up For SNBForums Daily Digest

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