Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jul 1st, 2006, 12:56 PM   #1
Delryn
Newbie
 
Join Date: Jul 2006
Posts: 3
Rep Power: 0 Delryn is on a distinguished road
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.
Delryn is offline   Reply With Quote
Old Jul 1st, 2006, 1:27 PM   #2
Delryn
Newbie
 
Join Date: Jul 2006
Posts: 3
Rep Power: 0 Delryn is on a distinguished road
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
Delryn is offline   Reply With Quote
Old Jul 1st, 2006, 2:16 PM   #3
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 4 Arevos is on a distinguished road
Quote:
Originally Posted by Delryn
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?
The lsof command lists open files on Linux systems. This includes IP connections (as everything in Unix is a file, yada yada). To list all open network connections:
lsof -i
To restrict this to external addresses (-n to remove hostnames):
lsof -i -n | egrep -v '\->(10\.|192\.168\.|127\.0\.0\.1)'
Well, you get the idea.

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:
Originally Posted by Delryn
how can I take the current time and tell if it falls within the restricted (7days a week) or the school (5days/week)
Might have to use a smidgen of Perl or Python for this, unless anyone knows any CLI commands that can do this. Why do you need this functionality, though? Isn't it just a case of enabling access at a certain time, and disabling it at another?
Arevos is offline   Reply With Quote
Old Jul 2nd, 2006, 2:03 PM   #4
Delryn
Newbie
 
Join Date: Jul 2006
Posts: 3
Rep Power: 0 Delryn is on a distinguished road
Quote:
Originally Posted by Arevos
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.

Might have to use a smidgen of Perl or Python for this, unless anyone knows any CLI commands that can do this. Why do you need this functionality, though? Isn't it just a case of enabling access at a certain time, and disabling it at another?
Thanks for the reply
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.
Delryn is offline   Reply With Quote
Old Jul 2nd, 2006, 2:22 PM   #5
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 4 Arevos is on a distinguished road
Quote:
Originally Posted by Delryn
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.
Using iptables, it's possible to write firewall rules that only apply to packets sent from certain users or groups of users. Here's a short article on how to achieve this.

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.
Arevos is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 6:34 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC