![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Jul 2006
Posts: 3
Rep Power: 0
![]() |
help needed for internet lockout
Hey folks
I'm new to this forum, so try not to hurt me too much....I might like it and stick around Anyway.. I'm trying my hand at bash scripting, starting with something that should be relatively simple.. Locking a teenage daughter out of the internet I've kinda figured out the means of doing it and the logistics of it I just need a bit of help with the small things...... like coding it Heres what I have at this point (I'll get to the actual questions at the end) Variables: - Status (another name may be more applicable) 0=out of time / grounded 1=default (X number of minutes per week) 2=school projects / good behavior (Y number of minutes added to X) 3=holidays (Z number of minutes replacing X) - Schedule a) restrictedstart (time of day when internet is denied to that user-probably 10pm) b) restrictedend (when internet is allow again-probably 6am) c)schoolstart (time of day that school starts - this would only affect mon-fri) d)schoolend (I think you get the picture) - TimeLeft a clock/timer that counts down X Using these variables pulled from a . file in the users $home I figure that I can control the weekly duration online. I think that I have figured out most of the conditional factors with regards to the above variables. Not coded, just figured out. At this point what I need help with is: determining if there are any internet accessing programs currently running, I presume the info has to coaxed out of ifconfig? how can I take the current time and tell if it falls within the restricted (7days a week) or the school (5days/week) if you can point me in the right direction it would be greatly appreciated, if you post code can I ask for detail documentation (I'm a bit slow learning new commands) Thanks Last edited by Delryn; Jul 1st, 2006 at 1:07 PM. |
|
|
|
|
|
#2 |
|
Newbie
Join Date: Jul 2006
Posts: 3
Rep Power: 0
![]() |
Just found this part out
ifconfig eth0 |grep bytes|cut -d":" -f2|cut -d" " -f1 ifconfig eth0 |grep bytes|cut -d":" -f3|cut -d" " -f1 run this through a loop a few times adding the differences... should provide a reasonable basis for internet activity |
|
|
|
|
|
#3 | ||
|
Programming Guru
![]() Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 4
![]() |
Quote:
lsof -i lsof -i -n | egrep -v '\->(10\.|192\.168\.|127\.0\.0\.1)' If you haven't thought of it already, the Linux firewall (iptables) is a good tool to use if you want to restrict network access in some fashion (either incoming, or outgoing). One could have a cron job that stops network access at X time, and another that enables it at Y. Quote:
|
||
|
|
|
|
|
#4 | |
|
Newbie
Join Date: Jul 2006
Posts: 3
Rep Power: 0
![]() |
Quote:
I had looked at iptables, and I will be using them to help filter the content on my computer. As for the timing, this is a shared computer. So I can't just arbitrarily have the system shutdown the internet. So I need to figure away of determining if the current user is allowed to be using the net at that specific time. |
|
|
|
|
|
|
#5 | |
|
Programming Guru
![]() Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 4
![]() |
Quote:
Presumably, you could have a series of cron jobs that enable/disable access on a per group basis. Thus, all users in a particular group would have their net access revoked from, say, 10pm to 6am, whilst those users not in that group would have free access. One could use iptables-save to construct several rulesets, and then use iptables-restore to update the firewall to use these rulesets at certain times. |
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|