Well I made this a looooong time back, might help someone!
#CREATED by mediator (digit forum)
#License : GPL3
if [ -z $1 ];then
echo "Argument 0 (DROP) or 1 (ACCEPT) required"
exit
fi
if [ $1 = '1' ];then
perm='ACCEPT'
else
perm='DROP'
fi
#Sites to block, add ur sites or IPs here
echo $perm
site=( microsoft.com youtube.com )
for (( i = 0; i < ${#site
[*]}; i++ ))
do
/sbin/iptables -I INPUT 1 -s ${site[$i]} -j $perm
/sbin/iptables -I OUTPUT 1 -d ${site[$i]} -j $perm
/sbin/iptables -I FORWARD 1 -d ${site[$i]} -j $perm
/sbin/iptables -I FORWARD 1 -s ${site[$i]} -j $perm
done
Aim : To block sites (packets), in and out and when forwarding packets.
Step to be taken :
1. "Save as say, 'mblock'"
2. "chmod +x mblock"
Usage :
"./mblock 0" => to drop
"./mblock 1" => to accept
"./mblock" => tells u what to do
U can add ur sites or IPs as shown in the bold in the quotes.
Helpful for the admins here! Though u can do the same via squid, but I find iptables and terminals much more realtime. U can also put the script in ur path to have an easy accessibilty.