Author Topic: How to block website by website's name  (Read 10213 times)

vinhky20119

  • Zen Apprentice
  • *
  • Posts: 14
  • Karma: +0/-0
    • View Profile
How to block website by website's name
« on: April 14, 2011, 01:01:48 pm »
Hi everybody,

I'm using Zentyal as my gateway, but I can't find where I can set a rule to block website by name, for example: I can block by public ip address when I use nslookup command, but in some cases I want to block by name like this http://*.google.com

Can we do this on Zentyal?

Sorry for my english.

Javier Amor Garcia

  • Zentyal Staff
  • Zen Hero
  • *****
  • Posts: 1225
  • Karma: +12/-0
    • View Profile
Re: How to block website by website's name
« Reply #1 on: April 14, 2011, 01:45:36 pm »
Sorry,  wildcard matches in domains is not supported.

macsit

  • Zen Apprentice
  • *
  • Posts: 1
  • Karma: +0/-0
    • View Profile
Re: How to block website by website's name
« Reply #2 on: April 14, 2011, 06:14:06 pm »
Hi everybody,

I'm using Zentyal as my gateway, but I can't find where I can set a rule to block website by name, for example: I can block by public ip address when I use nslookup command, but in some cases I want to block by name like this http://*.google.com

Can we do this on Zentyal?

Sorry for my english.


Try the www.opendns.com and choose a free version. See how you like it. There's the instructions how to setup on almost any routers inducing Zentyal as well.

Good luck!

Marcus

  • Forum Moderator
  • Zen Samurai
  • *****
  • Posts: 395
  • Karma: +12/-0
    • View Profile
    • Professional IT Service
Re: How to block website by website's name
« Reply #3 on: May 11, 2011, 08:35:17 pm »
Hello vinhky20119,

The proxy will be your friend on this one.

** Look for the tab named Domain Filtering in the HTTP Proxy section

Best,

Marcus

patmagee1024

  • Zen Apprentice
  • *
  • Posts: 14
  • Karma: +2/-0
    • View Profile
Re: How to block website by website's name
« Reply #4 on: May 16, 2011, 03:59:14 am »
I've been using ebox/Zentyal at home as my internet gateway for a couple of years now. Since I have Windows machines in the house I use SpyBot to deal with spyware. SpyBot does something very nice;They modify the hosts file and redirect those spyware places to the loopback address. It turns out this is a great way to block additional sites that are banned for the kids as well.

I realized I could use that hosts file to populate the Domain filtering in Zentyal and let it block all those sites from one place, giving me control from one location. I tried it and it worked flawlessly. Considering there were 10,000+ items in my hosts file I needed a better way to deal with it. As a result I wrote a little script to do the work for me. I have attached it below for anyone to use.

---------------------
Code: [Select]
#!/bin/bash

# Host file must be scrubbed and very clean. Sorted, uniq and one entry per line.
# Remove localhost entry and comments.
# Creates tarball of the hosts file.

clear
file1=~/hosts/hosts
file2=~/hosts/hosts.clean1
file3=~/hosts/hosts.sort1
file4=~/hosts/hosts.uniq1
file5=~/hosts/my.hosts
file6=~/hosts/hosts.tmp1
tarball=~/hosts/blacklist.tar.gz
folder=~/hosts

cd $folder

cat $file5 > $file6   # Push my custom hosts file to temp file
cat $file1 >> $file6 # Append windows hosts file to temp file
cat $file6 > $file1   # Overwrite original hosts file with combined data

# Ignore comment lines, localhost, strip loopback address and all whitespace
cat $file1 | grep -v '^#' | grep -v 'localhost' | sed -e 's/127.0.0.1//g' -e 's/[[:space:]]//g' > $file2
sort $file2 > $file3 # Sort the list
uniq $file3 > $file4 # Create a list of only unique items
cp -v $file4 $folder/blacklists/hosts/domains # Copy finished file into folder
tar cvpfz $tarball $folder/blacklists/*  # Tar it up for import

echo
echo "Complete. Check for errors. If none it's ready to import into Zentyal."

exit
# To import into Zentyal, use HTTP Proxy>Filter Profiles>default. Add under Domains filtering tab, Domains Lists Files, Add new and import.
# Name it MyHostsFile. On MyHostsFile, click icon under Categories and switch policy to always deny. Save it, changes are immediate.
---------------------

I have commented it so it's easier to follow. The last 2 commented lines tell you how to get it into Zentyal. (That's a reminder for me since I don't have to mess with it all that often. Could that be considered a testimonial? lol)

Now for a couple of comments after the fact.

I have custom host file entries I want blocked at all times, beyond what SpyBot does for me. Those go into file5 or my.hosts. The original Windows hosts file is copied in as hosts and is used as is. Of course, I already cleaned mine up.

Very important:One entry per line. Yes you can stack multiple host entries in a hosts file but we are converting this to something you can import into the filtering section. This is what I meant by cleaning mine up already. Also, strip out anything you DON'T want to filter out, like legitimate server names and IP addresses in your local network. Otherwise they will be blocked by the filter.

I hope you find this script useful.
« Last Edit: May 22, 2011, 01:00:15 am by patmagee1024 »