OpenWrt Forum Archive

Topic: Time measure

The content of this topic has been archived on 20 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hi,

I'm hoping to find some help in this forum. I need to create a solution with an OpenWRT Firmware to measure the time a special user is in the internet (and limiting it).

This is for the little sister of my girlfriedn. She is nearly 9 hours per Day online... Their parents are not very happy about this. A simple "No" seems not to work.

So my question: How to create such a setup? I think the best would be to create a user for her on the OpenWRT and let her "dail" in using PPP. But how limit the used time? Any Hints? I'm not a Linux beginner so the solution could be pretty complicated... But at the moment I have no Idea. :-/

Thanks for all helpfull thoughs

With best regards,
Stefan...

Hi,

I found an interesting patch in the netfilter's patch o matic package. What it does is :

This option adds CONFIG_IP_NF_MATCH_TIME, which supplies a time match module.
This match allows you to filter based on the packet arrival time/date
(arrival time/date at the machine which the netfilter is running on) or
departure time/date (for locally generated packets).

Supported options are:
[ --timestart value ]
    Match only if it is after `value' (Inclusive, format: HH:MM ; default 00:00).

[ --timestop  value ]
    Match only if it is before `value' (Inclusive, format: HH:MM ; default 23:59).

[ --days listofdays ]
    Match only if today is one of the given days. (format: Mon,Tue,Wed,Thu,Fri,Sat,Sun ; default everyday)

[ --datestart date ]
    Match only if it is after `date' (Inclusive, format: YYYY[:MM[:DD[:hh[:mm[:ss]]]]]
    h,m,s start from 0 ; default to 1970)

[ --datestop date ]
    Match only if it is before `date' (Inclusive, format: YYYY[:MM[:DD[:hh[:mm[:ss]]]]]
    h,m,s start from 0 ; default to 2037)

Example:
  -A INPUT -m time --timestart 8:00 --timestop 18:00 --days Mon,Tue,Wed,Thu,Fri
  will match packets that have an arrival timestamp in the range 8:00->18:00 from Monday
  to Friday.

  -A OUTPUT -m time --timestart 8:00 --timestop 18:00 --Days Mon --date-stop 2010
  will match the packets (locally generated) that have a departure timestamp
  in the range 8:00->18:00 on Monday only, until 2010

I think it could be a simple solution to make this girl stop surfing wink It just requires kernel patching and iptables patching, but if your familiar with linux it takes no time.

You can also define a static entry for her computer in /etc/dnsmasq.conf, and add a crontab denying all traffic coming from this host after n hour for instance.  This is another solution, maybe easier than the previous one ?

The easiest way would probably be to use a schedule.  For example, from 3-6 in the evening, or something like that.  You could then just use cron to add and remove access via the firewall...

Another idea would be to use the pptp server, and some shell scripts to count online time.  Using cron to launch a 'counter' script every five minutes, you could keep track of the amount of online time and limit it as necessary.  The counter script could work by pinging the IP address assigned to the pptp account. 

Could be a little tricky to get set up though...

Hm... pptp and Shellscripts. Yes, this might work and it looks more flexible than the other solution since I can control the whole time stuff. Not only *when* she is online but also how long. The Cron solution seems not really accurate but it should be good enough.

Perhaps someone has some other ideas or perhaps know software which exactly does what I'm searching for?

The discussion might have continued from here.