Parental control time limit for kids

Post new topic   Reply to topic    DD-WRT Forum Index -> General Questions
Goto page 1, 2  Next
Author Message
alhashemi
DD-WRT Novice


Joined: 15 Nov 2018
Posts: 1

PostPosted: Thu Nov 15, 2018 18:36    Post subject: Parental control time limit for kids Reply with quote
I am a newbie with DD-WRT. I have searched the forum for answers to my question but could not find an answer. Anyways, what I'm looking for is a way to control my kids access to the Internet by username/password combination and then give them limited time daily (say two hours per day). Can that be done?

Thanks in advance.
Sponsor
bushant
DD-WRT Guru


Joined: 18 Nov 2015
Posts: 2036

PostPosted: Thu Nov 15, 2018 19:00    Post subject: Reply with quote
Go to http://yourrouterip/Filters.asp. Enable Access Restrictions by Mac address and or IP address for the days and time of day. Fairly well explained here: https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=316069&highlight=
_________________
Forum Guide Lines (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!)
How to get help the right way

Before asking for help - Read the forum guidelines AND Upgrade DD-WRT!
Adblock by eibgrad (1.1M blocked) + Blocklist Collection

grc
DD-WRT User


Joined: 11 Jul 2018
Posts: 122

PostPosted: Thu Nov 15, 2018 21:48    Post subject: Reply with quote
configure hotspot in Services/Hotspot, e.g. Hotspot System

http://www.hotspotsystem.com/free-hotspot-basic
jrennie
DD-WRT Novice


Joined: 13 May 2020
Posts: 1

PostPosted: Wed May 13, 2020 21:26    Post subject: Reply with quote
I have the same question as alhashemi. bushant links to a discussion of how to limit access to certain times of the day, but I don't see mention of how to configure a usage time limit. For example, I'm flexible on when my child uses his tablet, but I only want him to use it for a total of 2 hours. https://wiki.dd-wrt.com/wiki/index.php/Parental_control shows how to block access during certain times of day, but doesn't describe how to limit usage within the allowed hours. I've found certain router software allowing this (e.g. Archer A6 https://www.tp-link.com/us/user-guides/Archer-A6_V2/chapter-7-parental-controls#ug-sub-title-1) and Nest Wifi, but support seems spotty.
Alozaros
DD-WRT Guru


Joined: 16 Nov 2015
Posts: 6446
Location: UK, London, just across the river..

PostPosted: Mon May 18, 2020 20:36    Post subject: Reply with quote
the way how i manage it...
Gargoyle-routers OS has limit quotas, by day, week, month or so...and its very useful...the only thing you need is UPS for the router...just bear in mind Gargoyle Os it not that safe and robust like DDWRT is...so run Gargoyle routers behind your main DDWRT router on diff subnet/NAT/DHCP/DNS only for internal stuff...like session management...
of course there are other ways to do it via entware package, but it requires more CLI stuff....

_________________
Atheros
TP-Link WR740Nv1 ---DD-WRT 55630 WAP
TP-Link WR1043NDv2 -DD-WRT 55723 Gateway/DoT,Forced DNS,Ad-Block,Firewall,x4VLAN,VPN
TP-Link WR1043NDv2 -Gargoyle OS 1.15.x AP,DNS,QoS,Quotas
Qualcomm-Atheros
Netgear XR500 --DD-WRT 55779 Gateway/DoH,Forced DNS,AP Isolation,4VLAN,Ad-Block,Firewall,Vanilla
Netgear R7800 --DD-WRT 55819 Gateway/DoT,AD-Block,Forced DNS,AP&Net Isolation,x3VLAN,Firewall,Vanilla
Netgear R9000 --DD-WRT 55779 Gateway/DoT,AD-Block,AP Isolation,Firewall,Forced DNS,x2VLAN,Vanilla
Broadcom
Netgear R7000 --DD-WRT 55460 Gateway/SmartDNS/DoH,AD-Block,Firewall,Forced DNS,x3VLAN,VPN
NOT USING 5Ghz ANYWHERE
------------------------------------------------------
Stubby DNS over TLS I DNSCrypt v2 by mac913
Wildlion
DD-WRT Guru


Joined: 24 May 2016
Posts: 1416

PostPosted: Mon May 18, 2020 22:43    Post subject: Reply with quote
Alozaros wrote:
the way how i manage it...
Gargoyle-routers OS has limit quotas, by day, week, month or so...and its very useful...the only thing you need is UPS for the router...just bear in mind Gargoyle Os it not that safe and robust like DDWRT is...so run Gargoyle routers behind your main DDWRT router on diff subnet/NAT/DHCP/DNS only for internal stuff...like session management...
of course there are other ways to do it via entware package, but it requires more CLI stuff....

+1 for Gargoyle Smile
Oilama
DD-WRT Novice


Joined: 13 Dec 2021
Posts: 1

PostPosted: Thu Dec 16, 2021 15:57    Post subject: Reply with quote
I'm a father of two kids, aged ten and fourteen. One of the more controversial things I do is limit the amount of time they can spend online. I don't make them get off the computer when they reach their time limit. Instead, I don't let them back on. That may sound harsh, but I think it's important for their sake that I set a limit — both for their good and for mine. You can read on https://www.familyorbit.com/blog/parental-controls-iphone/ how to restrict their time spent online. There you will find detailed steps.

Last edited by Oilama on Mon Dec 20, 2021 14:24; edited 1 time in total
pernils
DD-WRT Novice


Joined: 19 Dec 2021
Posts: 4

PostPosted: Sun Dec 19, 2021 21:12    Post subject: Reply with quote
Hi ...

After 1.5 days struggling I finally manage to get a script that will limits computer time per day of week for a ip address.
(not fully tested yet)

First you have to enable ssh, cron and jffs filesystem.

Save the script in /jffs/[scriptname]

Make it executable

Set up a cron job, lets say every 10 minutes

Tie the kids macaddress to a certain ip adress.

Edit time and ipaddress in the script and you should be rolling.

The script generate an access_log file in /tmp with timestamp and elapsed used time.
When limits is reach it writes iptables -I FORWARD [ipaddress] -j DROP
When the day rolls over to new day the counters is reset and is set iptables -I FORWARD [ipaddress] -j ACCEPT

You can anytime delete the access_log file in /tmp to reset the counters.

The script is a mess but this !/bin/sh forced me to use others methods to accomplish what I wanted.


Code:

#!/bin/sh
access_log=/tmp/lars_access
ipaddress=192.168.1.127
# limits in day of week in format hh:mm
limits1=01:10
limits2=01:10
limits3=00:05
limits4=00:05
limits5=02:30
limits6=02:30
limits7=00:05

u_time=00:00:00               # deafult counter value for user
s_time=$(date +"%T")      # default for last time stamp

ip=192.168.100.145               # ip to inflict restrictions


function delete_rules {
#iptables -S FORWARD

   nr=$(iptables -S FORWARD |grep -wn $ipaddress | cut -d: -f1 | head -n 1)
   while [ "$nr" \> 1 ]; do
      nr=$(($nr-1))
      iptables -D FORWARD $nr
      nr=$(iptables -S FORWARD |grep -wn $ipaddress | cut -d: -f1 | head -n 1)
      echo $nr
   done
#iptables -S FORWARD
}

function drop_ip {
   delete_rules
   iptables -I FORWARD -d $ipaddress -j DROP
}
function accept_ip {
   delete_rules
   iptables -I FORWARD -d $ipaddress -j ACCEPT
   echo accept
}

function write_log {
     echo write log $1
   touch $access_log                               # create new session_file
   echo $1 > $access_log                           # write current time stamp + used time
}

# session   sessions timestamp   : 2021-12-12T21:55:58
# s_date       session date         : 2021-12-12
# s_time    session time             : 21:55:58
# u_time      used time                 : 01:10

function read_session_log {
   if test -f "$access_log"; then                  # exists session_file ?
      savedIFS=$IFS
      IFS=T read -r s_date s_time u_time <$access_log    # split with T as delimiter to $s_date, $s_time $u_time
     IFS=$savedIFS
      if [ "$s_date" \< "$(date +"%F")" ]; then   # if new session of the day
#         u_time=00:00:00          # reset counter
         rm $access_log         # reset access_log file   
         write_log $(date +"%FT%T")T$u_time   # write new session time stamp
      fi
   else 
echo ny fil      
write_log "$(date +"%FT%T")T$u_time"      # init access_log file
   fi   
}

function validate_session {
   case $(date +%u) in
      1) maxlimits="$limits1"
      ;;
      2) maxlimits="$limits2"
      ;;
      3) maxlimits="$limits3"
      ;;
      4) maxlimits="$limits4"
      ;;
      5) maxlimits="$limits5"
      ;;
      6) maxlimits="$limits6"
      ;;
      7) maxlimits="$limits7"
   esac                                # maxlimits : 00:00

   if [ "$u_time" \< "$maxlimits" ]; then      # limits have not reach
#echo $u_time
#   if [ 1 \< 2 ]; then      # limits have not reach
      TIME1=$(date +"%T")                           # current time stamp
      TIME2=$s_time                                    # last checked time stamp


#TIME1=12:31:01
#TIME2=11:30:00

     # Convert the times to seconds from the Epoch
      SEC1=`date +%s -d ${TIME1}`
      SEC2=`date +%s -d ${TIME2}`


      # Use expr to do the math, let's say TIME1 was the start and TIME2 was the finish
      DIFFSEC=`expr ${SEC1} - ${SEC2}`
   
      DIFF=`date +%H:%M:%S -ud @${DIFFSEC}`   # format to hh:mm:ss

#echo $TIME1 - $TIME2  ===   $DIFF   utime $u_time
      dh=$(echo $DIFF |cut -f 1 -d ':')
      dm=$(echo $DIFF |cut -f 2 -d ':')
      ds=$(echo $DIFF |cut -f 3 -d ':')

      udh=$(echo $u_time |cut -f 1 -d ':')
      udm=$(echo $u_time |cut -f 2 -d ':')
      uds=$(echo $u_time |cut -f 3 -d ':')

#echo $udh $udm $uds
#echo $dh $dm $ds
 
      uds=$(($uds+$ds))            # adding
      udm=$(($udm+$dm))            # adding
      udh=$(($udh+$dh))            # adding

# echo utiem före $udh:$udh:$uds

   while  [ "$uds" \> "60" ]; do   # check against 60 sec
     udm=$(($udm+1))   
       uds=$(($uds-60))
   done

   while  [ "$udm" \> "60" ]; do   # check against 60 minutes
      udh=$(($udh+1))   
     udm=$(($udm-60))
   done
   
          if [ "$(expr length "$udh")" \< 2 ]; then
      udh=0$udh             
          fi
          if [ "$(expr length "$udm")" \< 2 ]; then
      udm=0$udm             
          fi
          if [ "$(expr length "$uds")" \< 2 ]; then
      uds=0$uds             
          fi
   u_time=$udh:$udm:$uds
   write_log $(date +"%FT%T")T$u_time   

      accept_ip # accept ip

   else

      drop_ip   # accept ip
   fi
}

#accept_ip
#drop_ip
#rm $access_log

 # read_session_log
 # validate_session
#iptables -S FORWARD      
#cat $access_log

 
#rm $access_log
#cat $access_log

# **************************
#      MAIN
# **************************

if arp | grep "($ipaddress)";
then
  read_session_log
  validate_session      
  iptables -S FORWARD      

  cat $access_log
fi
Alozaros
DD-WRT Guru


Joined: 16 Nov 2015
Posts: 6446
Location: UK, London, just across the river..

PostPosted: Mon Dec 20, 2021 10:46    Post subject: Reply with quote
huh that's a bit of a script...have you tried it ?

depends from router model and firmware number running...(you didnt mentioned those...)

That could be played out with one or few lines only..
based on this:

for external blocking lets say web sites and destinations:

iptables -I FORWARD -d 8.8.8.8 -m time --timestart 8:00 --timestop 18:00 --weekdays Mon,Tue,Wed,Thu,Fri,Sat,Sun --kerneltz -j REJECT

for local blocking lets say PC that has IP from your router range IP's:

iptables -I FORWARD -s 192.168.1.100 -m time --timestart 8:00 --timestop 18:00 --weekdays Mon,Tue,Wed,Thu,Fri,Sat,Sun --kerneltz -j REJECT


you can adjust days of the week and time...

but not all routers have this module (-m time)kerneltz..
for example Netgear R9000 or R7800 or even R7000 has it...those are large flash ram size routers...
Than again crafty kids may play a tricks and go around those rules, if they know what they are doing...its a cat's and dog's game..

_________________
Atheros
TP-Link WR740Nv1 ---DD-WRT 55630 WAP
TP-Link WR1043NDv2 -DD-WRT 55723 Gateway/DoT,Forced DNS,Ad-Block,Firewall,x4VLAN,VPN
TP-Link WR1043NDv2 -Gargoyle OS 1.15.x AP,DNS,QoS,Quotas
Qualcomm-Atheros
Netgear XR500 --DD-WRT 55779 Gateway/DoH,Forced DNS,AP Isolation,4VLAN,Ad-Block,Firewall,Vanilla
Netgear R7800 --DD-WRT 55819 Gateway/DoT,AD-Block,Forced DNS,AP&Net Isolation,x3VLAN,Firewall,Vanilla
Netgear R9000 --DD-WRT 55779 Gateway/DoT,AD-Block,AP Isolation,Firewall,Forced DNS,x2VLAN,Vanilla
Broadcom
Netgear R7000 --DD-WRT 55460 Gateway/SmartDNS/DoH,AD-Block,Firewall,Forced DNS,x3VLAN,VPN
NOT USING 5Ghz ANYWHERE
------------------------------------------------------
Stubby DNS over TLS I DNSCrypt v2 by mac913
egc
DD-WRT Guru


Joined: 18 Mar 2014
Posts: 12915
Location: Netherlands

PostPosted: Mon Dec 20, 2021 11:11    Post subject: Reply with quote
Nice work but as @Alozoros already said I think you can simplify it with the time module and using IPSET

See the IPSET instructions which also has a paragraph about the time module:
https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=327261

_________________
Routers:Netgear R7000, R6400v1, R6400v2, EA6900 (XvortexCFE), E2000, E1200v1, WRT54GS v1.
Install guide R6400v2, R6700v3,XR300:https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=316399
Install guide R7800/XR500: https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=320614
Forum Guide Lines (important read):https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=324087
pernils
DD-WRT Novice


Joined: 19 Dec 2021
Posts: 4

PostPosted: Tue Dec 21, 2021 10:57    Post subject: Reply with quote
Router model :Asus RT-AC680U C1
dd-wrt fw : v3.0-r46316 std (04/09/21)

Read throw the ipset pdf but I didn't manage to get my head around on how to achieve my goal.

My goal is to set a fixed total timeslot on certain ip.

The "owner" of that ip can then decide how he/she distribute the internet time during the day.

The script check with arp if the ip is active and then counts up the counter from the last check.

So if the user don't use the internet (in other word he/she have shut down the device) the counting stops until he/she starts up the device again.
Hmm I think this script will not work on tablets as they are broadcasting now and then.

The current parent control in dd-wrt just sets a window where access is allowed. I want to set fixed time for example 1 hour and 15 minutes.
Alozaros
DD-WRT Guru


Joined: 16 Nov 2015
Posts: 6446
Location: UK, London, just across the river..

PostPosted: Tue Dec 21, 2021 13:33    Post subject: Reply with quote
pernils wrote:
Router model :Asus RT-AC680U C1
dd-wrt fw : v3.0-r46316 std (04/09/21)

Read throw the ipset pdf but I didn't manage to get my head around on how to achieve my goal.

My goal is to set a fixed total timeslot on certain ip.

The "owner" of that ip can then decide how he/she distribute the internet time during the day.

The script check with arp if the ip is active and then counts up the counter from the last check.

So if the user don't use the internet (in other word he/she have shut down the device) the counting stops until he/she starts up the device again.
Hmm I think this script will not work on tablets as they are broadcasting now and then.

The current parent control in dd-wrt just sets a window where access is allowed. I want to set fixed time for example 1 hour and 15 minutes.


well..that's where i use my Gargoyle router, as there is a quota option...and it works out of the box...sadly in DDWRT there is not such a extra yet...just make sure you dont use it as an edge router as im not sure how well is maintained towards security patches...but it should provides some basic safe and sound level...

_________________
Atheros
TP-Link WR740Nv1 ---DD-WRT 55630 WAP
TP-Link WR1043NDv2 -DD-WRT 55723 Gateway/DoT,Forced DNS,Ad-Block,Firewall,x4VLAN,VPN
TP-Link WR1043NDv2 -Gargoyle OS 1.15.x AP,DNS,QoS,Quotas
Qualcomm-Atheros
Netgear XR500 --DD-WRT 55779 Gateway/DoH,Forced DNS,AP Isolation,4VLAN,Ad-Block,Firewall,Vanilla
Netgear R7800 --DD-WRT 55819 Gateway/DoT,AD-Block,Forced DNS,AP&Net Isolation,x3VLAN,Firewall,Vanilla
Netgear R9000 --DD-WRT 55779 Gateway/DoT,AD-Block,AP Isolation,Firewall,Forced DNS,x2VLAN,Vanilla
Broadcom
Netgear R7000 --DD-WRT 55460 Gateway/SmartDNS/DoH,AD-Block,Firewall,Forced DNS,x3VLAN,VPN
NOT USING 5Ghz ANYWHERE
------------------------------------------------------
Stubby DNS over TLS I DNSCrypt v2 by mac913
egc
DD-WRT Guru


Joined: 18 Mar 2014
Posts: 12915
Location: Netherlands

PostPosted: Tue Dec 21, 2021 13:37    Post subject: Reply with quote
To check if you have ipset you can do: "which ipset" from CLI e.g. on my EA6900:

Code:
root@EA6900:~# which ipset
/usr/sbin/ipset
root@EA6900:~#

_________________
Routers:Netgear R7000, R6400v1, R6400v2, EA6900 (XvortexCFE), E2000, E1200v1, WRT54GS v1.
Install guide R6400v2, R6700v3,XR300:https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=316399
Install guide R7800/XR500: https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=320614
Forum Guide Lines (important read):https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=324087
pernils
DD-WRT Novice


Joined: 19 Dec 2021
Posts: 4

PostPosted: Tue Dec 21, 2021 15:03    Post subject: Reply with quote
Seems I have ipset after all.

/usr/sbin/ipset

From this it seems you can indeed set a timeout

https://superuser.com/questions/1412286/time-limited-whitelisting-of-ip-addresses-with-ipset-and-iptables

I have no idea how it would play out if the user only uses half of its quota and resume lets say after 3 hours.

Could you give an example on ipset with a quota of 1 hour / day ?


(meanwhile i mess around with my script to get it more users friendly..)
egc
DD-WRT Guru


Joined: 18 Mar 2014
Posts: 12915
Location: Netherlands

PostPosted: Tue Dec 21, 2021 17:49    Post subject: Reply with quote
IPSET has a timeout option which might do the trick but I have never used it
_________________
Routers:Netgear R7000, R6400v1, R6400v2, EA6900 (XvortexCFE), E2000, E1200v1, WRT54GS v1.
Install guide R6400v2, R6700v3,XR300:https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=316399
Install guide R7800/XR500: https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=320614
Forum Guide Lines (important read):https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=324087
Goto page 1, 2  Next Display posts from previous:    Page 1 of 2
Post new topic   Reply to topic    DD-WRT Forum Index -> General Questions All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum