Installing Dansguardian on LinuxMCE
Draft page
Still under draft and yet to finalize... Thanks
Basics
DansGuardian is an award winning Open Source web content filter which currently runs on Linux, FreeBSD, OpenBSD, NetBSD, Mac OS X, HP-UX, and Solaris. It filters the actual content of pages based on many methods including phrase matching, PICS filtering and URL filtering. It does not purely filter based on a banned list of sites like lesser totally commercial filters.
DansGuardian is designed to be completely flexible and allows you to tailor the filtering to your exact needs. It can be as draconian or as unobstructive as you want. The default settings are geared towards what a primary school might want but DansGuardian puts you in control of what you want to block.
DansGuardian is a true web content filter. We will see how to configure DansGuardian on Ubuntu Linux along with LinuxMCE.
Installing packages
tinyproxy
apt-get install tinyproxy
shorewall
apt-get install shorewall
dansguardian
apt-get install dansguardian
dhcp
apt-get install dhcp3-server
dns server
apt-get install dnsmasq
Optional:
Dansguardian Web Log Viewer
apt-get install dglog
Configure Packages
Tinyproxy
vi /etc/tinyproxy/tinyproxy.conf
Make the following changes
- User root
- Group root
- Allow 192.168.80.0/25
Dansguardian
vi /etc/dansguardian/dansguardian.conf
Make the following changes:
- Delete UNCONFIGURED line
- filterport = 8081
- proxyip = 192.168.80.1
- proxyport = 8888
- usernameidmethodproxyauth = off
Shorewall
Make the following changes: set "shorewall" auto start at boot time:
vi /etc/default/shorewall
- startup = 1
"zones" tells the firewall to zone each name for the rest configuration file e.g. loc, net:
vi /etc/shorewall/zones
- #ZONES TYPE OPTION IN OUT
- #OPTIONS OPTIONS
- fw firewall
- net ipv4
- loc ipv4
- #Last Line - ADD ENTRIES ABOVE THIS ONE - DO NOT REMOVE
"interfaces" tells the firewall which is internal and external interfaces:
vi /etc/shorewall/interfaces
- #ZONE INTERFACE BROADCAST OPTIONS
- #Note assuming "eth1"- is internal ip & "eth0"- is external ip
- net eth0 detect dhcp,tcpflags
- loc eth1 detect dhcp
- #LAST LINE --ADD YOUR ENTRIES ABOVE THIS ONE - DO NOT REMOVE
"masq" tells the firewall that internal network(eth1)is connected through external network(eth0):
vi /etc/shorewall/masq
- #INTERFACE SUBNET ADDRESS PROTO PORT(S) IPSEC
- eth0 eth1
- #LAST LINE --ADD YOUR ENTRIES ABOVE THIS ONE - DO NOT REMOVE
"policy" tells the firewall that how should handle the requests:
vi /etc/shorewall/policy
- loc all ACCEPT
- net all DROP
- fw all ACCEPT
- all all REJECT
"shorewall.conf" we will configure ip_forwarding:
vi /etc/shorewall/shorewall.conf
- IP_FORWARDING=On
"rules" allows to set firewall rules:
vi /etc/shorewall/rules
- SECTION NEW
- ACCEPT net fw tcp 80
- REDIRECT loc 8081 tcp www
- ACCEPT loc fw tcp 22
- ACCEPT net fw icmp
- ACCEPT loc loc icmp
- #LAST LINE --ADD YOUR ENTRIES ABOVE THIS ONE - DO NOT REMOVE
# check shorewall working or not properly shorewall check
Restart Applications
/etc/init.d/dnsmasq restart /etc/init.d/tinyproxy restart /etc/init.d/shorewall restart /etc/init.d/dansguardian restart
DHCP Server
Note: you need not to make any changes if you are working on single system or dhcp is already running on your local network interface(any changes dhcpd.conf or interfaces respective files)
vi /etc/default/dhcp3-server
- INTERFACE="eth1"
vi /etc/dhcp3/dhcpd.conf
- #change the subnet, netmask, range, dns, router as per your settings
- default-leasetime=86400
- max-leasetime=60480
- subnet 192.168.0.0 netmask 255.255.255.0{
- range 192.168.0.2 192.168.1.99;
- option domain-name-server 192.168.80.1;
- option routers 192.168.80.2;
- }
set static ip address:
vi /etc/network/interfaces
- auto lo
- iface lo inet loopback
- auto eth1
- iface eth0 inet static
- address 192.168.80.1
- netmask 255.255.255.0
#restart dhcp
- /etc/init.d/dhcpd restart
Troubleshooting
- Still not working restart the system once
- Check all service started are not "ps -ef | grep <service>" service - apache2, dnsmasq, tinyproxy, shorewall, dansguardian, and dhcpd. If any of the service is not starting, start the service sh /etc/init.d.<service> start. Check especially dnsmasq and shorewall services.
Adding BlackList
A BlackList is a precompiled list of sites that are deemed potentially worrisome.
cd /etc/dansguardian wget http://urlblacklist.com/downloads/OriginalUpdateBL vi OriginalUpdateBL
- modify line 68 by switching the listed URL with the following:
- http://urlblacklist.com/cgi-bin/commercialdownload.pl?type=download&file=bigblacklist
chmod 777 /etc/dansguardian/OriginalUpdateBL /etc/dansguardian/OriginalUpdateBL
when script is finished if you see any errors.
/etc/init.d/dansguardian restart
if the above script is not creating blacklists directory and creating blacklists file then follow the following:
cd /etc/dansguardian wget http://urlblacklist.com/cgi-bin/commercialdownload.pl?type=download&file=bigblacklist tar -xvf bigblacklist.tar.gz chown -R root:root blacklists chmod -R 755 blacklists