New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus Advice and insight from world-class Apple enthusiasts Exclusive access to members-only contests, giveaways and deals

Join today!

Start a Discussion

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
Internet, Networking, and Wireless Discussion of networking, internet, and wireless including Apple's Airport products.

script to blackhole a website after an hour

Post Reply New Thread Subscribe

Thread Tools

Member Since: Jan 29, 2012
Posts: 2
dmjlambert is on a distinguished road

dmjlambert is offline
I would like to write a script which will use the route command to interrupt access to a website for the rest of the day one hour after detecting first use of the day. I will use the route command to blackhole the address. The idea here is to limit facebook access to just an hour a day. I plan to build these features into the script, which will run via cron every 15 minutes or so:

1. check what DNS addresses were used by various web browsers and apps on the computer over the last hour and build a table of what was done at what time.
2. read a configuration file which has a list of websites to blackhole and an optional number of minutes to wait before blackholing,
3. if sufficient time has passed blackhole the site with a command similar to route add `host| awk '{print $NF}'`
4. add the site name and IP address to a text table.
5. go through the table and make sure any additional addresses for the sites in the config file are also blackholed.
6. if midnight, remove the blackhole routes and flush DNS cache

I can do all of this except I don't know how to do #1 on my list. Is it possible using built-in Mac utilities (I would prefer not to download freeware/shareware such as djbdns for this) to look in a log file or somehow look up what has been queried in DNS over the last hour or so? Can I turn on logging for the DNS client or somehow tell what the DNS client has done recently?

QUOTE Thanks

Member Since: Jan 29, 2012
Posts: 2
dmjlambert is on a distinguished road

dmjlambert is offline
I forgot to mention, I am talking about doing this on macbooks running Snow Leopard and Lion.
QUOTE Thanks

Post Reply New Thread Subscribe

« Modem/ Switch problems. | USB wireless Adapter Issues »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
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
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Starter
Last Post
I want to launch firefox 2.0 from an icon and launch a specific website bobotech OS X - Operating System 1 07-15-2011 05:20 PM
Unable to Connect to Specific Website raqk8 OS X - Operating System 5 05-31-2011 06:37 PM
Script to duplicate Apple Lossless iTunes library as MP3 files nick_harambee OS X - Operating System 10 10-02-2010 08:53 AM
Video intro for website simo719 Web Design and Hosting 3 08-14-2010 01:18 PM
Prevent script from running on home network rbrock OS X - Operating System 0 04-27-2010 12:10 PM

All times are GMT -4. The time now is 01:13 PM.

Powered by vBulletin
Copyright ©2000 - 2015, Jelsoft Enterprises Ltd.

Welcome to

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!

(4 digit year)

Already a member?