[Dnsmasq-discuss] URL filtering

Paul Chambers dnsmasq at lists.bod.org
Tue Mar 17 14:50:00 GMT 2009


It's not that hard to set something up. Though it does require multiple 
pieces.

I have a cron job that runs daily:
______________

#!/bin/sh
wget --quiet \
     --output-document=/etc/dnsmasq.d/adservers \
 
"http://pgl.yoyo.org/adservers/serverlist.php?hostformat=dnsmasq&showintro=0&mimetype=plaintext&useip=10.11.1.2"
sed -i \
     -e 's/127\.0\.0\.1/10.11.1.2/' \
     -e '/google/ d' \
     -e '/constantcontact.com/ d' \
     /etc/dnsmasq.d/adservers
/etc/init.d/dnsmasq restart
______________

Basically, pull the pgl list from pgl.yoyo.org, fix up the addresses it 
contains, remove some servers I don't want blocked, then restart dnsmasq 
so it picks up the new list.

I've added an alias on my internal network interface for 10.11.1.2 
(eth1:0), and then in /etc/httpd/conf.d I've added a file that contains:
______________

<VirtualHost 10.11.1.2:80>
     ServerName block.bod.org
     DocumentRoot /var/www/block-ads
     ServerAdmin webmaster at bod.org

     ErrorLog logs/block_error.log
     CustomLog logs/block_access.log combined

     RewriteEngine On
     RewriteRule ^(.*)$ /blocked.html [L]

</VirtualHost>
______________

Basically, any http accesses to 10.11.1.2 will be served blocked.html, 
irrespective of the full URL.

Using squid (or privoxy) as a transparent http proxy is more 
sophisticated, and I may switch to that method eventually. But for now, 
this works pretty well.

Hope this helps,

-- Paul


conn intel wrote:
> Dear Friends,
> 
> Do it supports URL filtering similar to OPENDNS which has whitelist 
> category ? or can anyone suggest how can I achieve it ?
> 
> Kindly let me know if someone need further information.
> 
> Thank you,
> Ankur.
> 



More information about the Dnsmasq-discuss mailing list