Posted: Sat Dec 30, 2023 14:54 Post subject: Script Request: WPS button temp toggle blocked service
Hello. I'm running an old WRT54G router as a client. It's running firmware v24-sp2 (10/10/09 micro).
I am looking to set this thing up with a script where upon pressing the SES/WPS button it blocks traffic on a specific port for 10 seconds and then enables it again.
I defined a custom service under Access Restrictions -- WAN Accesss -- Blocked Services. If possible, I'd like the script to toggle that blocked service on for 10 seconds then disable it once done upon button press. Or if there's a simpler way please let me know.
I am new to scripting on this so any help would be greatly appeciated as I have had no luck searching, other than to find a script that blinks the led 10 times found here: https://wiki.dd-wrt.com/wiki/index.php/SES_Button
Joined: 26 Mar 2013 Posts: 1858 Location: Hung Hom, Hong Kong
Posted: Sun Dec 31, 2023 10:53 Post subject:
A simple method to debug your script is to use the command logger:
Code:
#!/bin/sh
#
# This is a script to be executed by SES/WPS button ($$ is process ID)
# You can save it as testing123.sh, and have it hooked to the SES/WPS button.
#
logger -s -t testing123 "[$$]Entering SES/WPS script"
sleep 10
logger -s -t testing123 "[$$]Exiting SES/WPS script"
You can then read the system log and find messages created above:
Code:
grep testing123 /var/log/messages
_________________ Router: Asus RT-N18U (rev. A1)
Drink, Blink, Stretch! Live long and prosper! May the Force and farces be with you!
After much struggle with trying to write something using iptables I abandoned that and found the following links and was able to get something together that works. Here's the script I came up with with references to topics that helped:
Works as expected for me. After setting up the access restriction rule, saving this script in "startup" under Administration -- Commands, and pressing the SES/WPS button enables the access restriction rule (in this case, rule number 1 with the rule name "ruleName") for 10 seconds and then disables it again.