So I was trying to do what @allanp81 suggested...
And using my own criteria, I want to block the Amazon Kindle Reader website (and have it not resolve). This is what I'm using but I'm getting a permission denied. Anyone have any thoughts?
sudo echo 0.0.0.0 read.amazon.com >> /private/etc/hosts
I've also tried
sudo echo 0.0.0.0 read.amazon.com >> /etc/hosts
Thanks so much in advance!
Sorry, perhaps I wasn't clear. The permission denied was in Terminal... so even now when I type:
sudo echo 18.104.22.168 read.amazon.com >> /etc/hosts
I am still getting a permission denied.
My command 0.0.0.0 does however work (and simply gives an error page which I don't mind) when using the Nano text editor, however I won't be able to use that with Jamf. Obviously I need to deploy this via a script and deploy (right?).
Would this work?
#!/bin/sh # Check if there is a line in /etc/hosts containing "read.amazon.com". # If it doesn't then add it, else it if exists replace it with new line. if grep -q "read.amazon.com" /etc/hosts; then echo "Redirect exists for read.amazon.com, replacing with new..." # Remove line /usr/bin/sed -i_bak -e '/read.amazon.com/d' /etc/hosts # Add redirect echo "22.214.171.124 read.amazon.com" >> /etc/hosts # Reset DNS /usr/bin/killall -HUP mDNSResponder else echo "Redirect does not exist for read.amazon.com, adding it now..." # Add redirect echo "126.96.36.199 read.amazon.com" >> /etc/hosts # Reset DNS /usr/bin/killall -HUP mDNSResponder fi exit 0
Yes!!! Now I have just one more question. If I want this (for one of my students) to only be effective while he's in school, I know how to make the policy work during those hours. However what script would I write to make this reverse during the hours he's not in school? Basically it's ok for him to read Kindle via the browser at home, just not at school.
Thank you so much for that script. Was awesome.