What's new

Parental control the SH way

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

itpp20

Senior Member
My own confoxtal the easy way (at least for me);

#!/bin/sh

# /jffs/scripts/services-start

cru a blockdev "30 22 * * sun,mon,tue,wed,thu sh /jffs/scripts/blockdev.sh"
cru a relall "0 7 * * * sh /jffs/scripts/relall.sh"
cru a relallwk "28 0 * * sun,sat sh /jffs/scripts/relall.sh"
cru a blockdevwk "30 0 * * sun,sat sh /jffs/scripts/blockdev.sh"


Control script:

#!/bin/bash

# /jffs/scripts/blockdev.sh

echo "#!/bin/bash">/jffs/scripts/relall.sh
echo "">>/jffs/scripts/relall.sh
chmod a+rx /jffs/scripts/relall.sh

# copy below block for other devices, copy MAC address from dhcp list from GUI asus

# Samsung(android)_My_Son
mmac=AA:BB:7B:C6:55:44
vmac=$(echo "$mmac" | awk '{print tolower($0)}')
kmmac=$(cat /var/lib/misc/dnsmasq.leases | grep "$vmac" | cut -d" " -f3)
if ! [ -z "${kmmac}" ]; then iptables -I FORWARD -s $kmmac -j DROP; fi
if ! [ -z "${kmmac}" ]; then conntrack -D --src=$kmmac; fi
if ! [ -z "${kmmac}" ]; then echo iptables -D FORWARD -s $kmmac -j DROP>>/jffs/scripts/relall.sh; fi


On school days cut off internet at 22:30, on weekends at 00:30, release all days at 07:00

# Example of Cron job definition:
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * user-name command to be executed

Have fun and be amazed your son/daughter wants to go to bed at 22:31 :cool:
 
The router's firmware doesn't have /bin/bash.

EDIT: The HND routers now have /bin/bash but it's only a symlink to busybox so there's still no support for bash specific commands (like arrays).

confoxtal?
 
Last edited:
The router's firmware doesn't have /bin/bash.

Correct, but as it happens, it doesn't matter. The OP is calling sh and passing the script(s) as an argument, so it works. If only for reasons of clarity, the references to /bin/bash should probably be changed to /bin/sh.

Regardless, thanks for the script.
 
Last edited:
Hello,

Thank you ittp20 for sharing this. Very interesting.

From an intellectual standpoint, I like the idea of not "overloading" the router and not checking packets when there are no traffic restrictions.

I'm curious, have you by any chance, noticed a performance hit when using iptables to check the timeslots ?, with things like

iptables -t filter --insert FORWARD 2 -m time --timestart 00:00:00 --timestop 08:00:00 --kerneltz

Or were you more inclined to use cron anyway.

BTW: In my area, 400Mbps is the best consumers can get at the moment. So, not Gbps for us so far. I guess it depends a lot on how much/fast you need to get from the router/line.

Best regards
Take care
W.
 
Cron(winscp) is easier to manage than iptables(ssh) and iptables by itself can't translate mac to ip and when the time comes he gets smart about changing mac I'll be 2 steps ahead by using cron :D

When it comes to GB on your LAN2WAN, my car can do 260kph but I see no point exceeding 140kph so in its lifetime it will be stuck at 140kph. The moral? whats the point in all those efforts in GB when you can do everything already with the 150-300? You can map the users one on one with problems and trying to get max on wifi.

I guess it depends a lot on how much/fast you need
Thats typical marketing BS turning you in to a lemming.
 
Thank you for the feedback. Neat solution.
 

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