Archive for the 'Open Source' Category

We HERE!!!

Friday, October 19th, 2007

We made it to our hotel in Nashville about 9:00 last night.  We would have made it sooner, but Adam made a wrong turn at the last minute, and we spent about 20 minutes driving around Nashville trying to find our way.  We picked up a map of Nashville at a tourist center, but in the end it was the satellite image I printed off for the WiFi race that got us going in the right direction.

So today PhreakNIC begins, and the RootWar.  I should be meeting Jeff soon and we’ll work on setting everything up.

I managed to come up with some decent wifi equipment, though I had to hack together some adapters so I could connect the high-gain omni-directional antenna to my laptop.  Thankfully, I brought my soldering iron with me and I managed to get it all working.  I haven’t done any field testing yet, so I really don’t know how much distance we’ll get with our equipment, but the general idea is we’ve got an omni-directional antenna that we’ll try to mount on top of the van, and a directional antenna that will be in the van with us, mounted on a tripod.  The omni-directional will let us know we’re in the vicinity of our target, and the directional will help us figure out exactly where the target is.

In other news, Gutsy Gibbon was released yesterday, so I’m upgrading now.

M$ vs. Linux

Sunday, September 30th, 2007

Someone brought this article to my attention this week, so I put my rebuttal here. Not entirely comprehensive, but it’s a start. Not meaning to start another M$ v Linux war here, but what’s your take?

Snort & Nagios

Wednesday, September 26th, 2007

I put it off for awhile, but I finally got around to getting Snort up and running.  It was actually pretty easy to get it working.  Since I’m using OpenBSD all I had to do was:

# pkg_add snort-2.6.0.2p1-mysql

And then it was installed.  I used Oinkmaster to download the rules I needed, and it all just worked.  Now I need to work on configuring some kind of user interface to make going through the logs easier.  At this point I’ve got 600K of logs to browse for a single day’s activity.  I know there are some nice GUI’s out there to make this easier, so when I get a chance, I’ll look into that and find something useful.

On another topic, I’ve also finally gotten around to getting Nagios setup.  I’m tweaking what I want monitored and what kind of alerts I want to get.  I’m going through all our mission-critical systems and figuring out what I want to monitor so I can catch any problems before they become problems.  Once I get the monitoring setup, I need to figure out how I want to be alerted.  I’m thinking I’ll use SMS.  With my current phone plan it will be cheaper than having my phone check email on a regular basis.  I wonder if Snort and Nagios can work together?  It doesn’t seem so far fetched that I could configure snort to send alerts for specific rules to Nagios.  It’s worth looking into.

Samba 4 Alpha is Out!!!

Wednesday, September 5th, 2007

The Alpha version of Samba 4 is now available.  I installed the last technical preview of Samba 4, but never really got around to testing it.  I’ve been pretty busy.   When I setup the servers recently, I created several empty partitions that I can use to add more VM’s.  So I’m thinking I can setup a Samba 4 VM on the server.  It should perform better than the VM I was running on my laptop.  I’m eager to see AD working on a Linux server!!

According to the WHATSNEW.txt file, some of the features that now work in alpha one that didn’t work in the last technical preview include:

Group Policy Support!!!
MMC Support:  We can now use AD Users and Computers

There are of course several other changes, but these two will make a HUGE difference when supporting Windows clients with a *nix server.

Some things that don’t work:

No printing support
Samba 4 works best as a PDC, and doesn’t support being a domain member very well
Apparently managing groups still needs some work
If your clocks aren’t in sync you’ll get some Kerberos errors

So it still needs some work, but I’m VERY excited!!!  If everything works the way the Samba development team plans for it to I believe this will go a long ways in making Linux more of an appealing server OS for all those Windows shops out there.  If I get a chance to play with it I’ll be sure to let you know how it goes.

Is the End of FREE Open Source Near?

Thursday, August 9th, 2007

I remember many years ago when I first started to program, and began learning about databases, the first database server I tried was MySQL. What I read about it claimed that MySQL was the best performing database server available, plus it was multi-platform, free and Open Source. What could be better?

Last year MySQL split into two products, the free open source community version, and a paid-for enterprise version. While the paid-for version wasn’t free, the source code was still available… until now.

It hasn’t been made very public, but MySQL now no longer provides a source tarball for the enterprise version of MySQL unless you’re a paying customer. It would seem there has been a trend in the OSS (open source software) that I’m not so sure I’m fond of. I remember the day when open source was more or less synonymous with free. That’s not so much the truth today. More and more OSS companies that used to provide all their software for free now provide an enterprise paid-for version and a free community version. Red Hat, for example, was the first Linux distro I ever tried out, I remember spending a couple days to download it, and it probably took me a couple more days going through different websites figuring out how to install it. And of course the best part of it all was that it was FREE!! Then Red Hat switched to RHEL (Red Hat Enterprise Linux) which is NOT FREE, and Fedora (the free version) forked off it. SuSE is another Linux distro that has split into a free and a paid-for version.

As the IT Director of an NPO with a small IT budget, FREE OSS is my best friend. I can provide enterprise-level software for my network without an enterprise-level budget. Now I’m beginning to wonder, will I still be able to in years to come?

OK, so these are the consernce, but the truth is OSS is driven by the community, not the corporations. As OSS grows in popularity more and more companies are going to try to profit from it, but the community will still be here, and the community will continue to provide great free open source software for us and our users to use.  So IS THE END OF FREE OSS NEAR?  ABSOLUTELY NOT!!!

They may take MySQL, but they will never take our FREEDOM!!

LONG LIVE OPEN SOURCE!!

Samba 4 Review

Thursday, July 19th, 2007

Technical Preview 5 of Samba 4 recently came out. So I’ve downloaded it and will try to install it on an Ubuntu virtual machine running on VMWare. And because I’m such a nice guy, I’ll let you share the experience with me.

I’m starting with a basic Ubuntu Server 7.04 Feisty Faun configured as a LAMP server. It’s a standard VM I carry around on my laptop. Before I can compile Samba, I need to download and install some dependencies:

# sudo apt-get install autoconf make gcc gettext libreadline5-dev libgnutls-dev libacl1-dev attr

Now download the source from Samba and untar it:

# wget http://us1.samba.org/samba/ftp/samba4/samba-4.0.0tp5.tar.gz
# tar xvzpf samba-4.0.0tp5.tar.gz

Be sure to read the README and the howto.txt which most of what follows is based on. For tp5 you will need to generate the configure script. So do the following:

# cd samba4/source
# ./autogen.sh

Now we have a configure script, so run it:

# ./configure

And then we make stuff. (Note: adding proto to ‘make all’ will make samba4 compile about 5x faster if you have a recent version of gcc, 3.4 or higher, which you should have if you’re following this tutorial)

# make proto all

Now make sure you’re root and:

# make install

If you’ve EVER compiled anything in *nix this should all be familiar. If you’ve never compiled anything before, and perhaps don’t even know what compile means, then why are you trying to install a technical preview of ANYTHING? Let’s continue…

Now we must use the ‘provision’ command to set up a basic user database. I’m assuming you’re following along and still in the samba4/source directory. You will need to make sure ’smbscript’ is in your path. I did this by:

# PATH=$PATH:/usr/local/samba/bin

You should also add the above to your .profile so it stays in your PATH. Before you’re finished you’ll need /usr/local/samba/sbin in your PATH as well.

Now you can:

# ./setup/provision –realm-YOUR.REALM –domain=YOURDOM ==adminpass=SOMEPASSWORD

Now you’re about ready to go, but we need to setup a share in /usr/local/samba/etc/smb.conf. Edit smb.conf and add something like:

[test]
path = /data/test
read only = no

Now that we’re all setup all you need to do is start samba:

# smbd

There you go. It’s up and running. You can share files and there should be some AD functionality. I was able to access the ‘Test’ share we setup earlier. I was also able to access SWAT by browsing to http://localhost:901. From SWAT I can currently add new users, provision the database, and import users from Samba3 or Windows. There’s also a link to run some ESP tests and a link to preview the NEW SWAT, but neither one of these work after following the above steps.

One last thing you’ll want to do that’s in the howto.txt document. You’ll want to make certain the partition hosting your shares is mounted with the user_xattr option by editing your /etc/fstab file. I changed the appropriate line in mine like so:

# /dev/sda1 / ext3 user_xattr

Then reboot:

# mount -o remount

[thanks to Matt for pointing out the original error here, you don't have to reboot]

You’ll need to do this to be certain you can support the new features of Samba4. There are some other things listed you might want to do in the howto.txt document, but the above seemed to be enough to pass all the tests listed.

I’m afraid that’s as far as I go tonight. Over the next couple weeks, when I have time, I’ll try to test out some of the functionality and I’ll get back to you. According to all the documentation I’ve read the features that work are stable, but it’s still just a technical preview, so there’s several features that simply haven’t been coded yet. I’ll see what kind of tests I can come up with, and I’ll get back to you.

Samba 4

Tuesday, July 17th, 2007

Speaking of Sama, Technical Preview 5 (TP5) for Samba 4 came out last month. And what’s so great about Samba 4? It’s a little thing called Active Directory. Until now, using Samba as a PDC only gave you NT4 functionality, but with Samba 4 comes promises of full AD integration. It will include it’s own LDAP server and it’s own Kerberos implementation.

I’ve been watching this project for some time. Working for an NPO (Non-Profit Organization) we don’t have much of an IT budget, so when it came time to buy a server, I put all the money I had into hardware, and had to use free software. Now don’t get me wrong, I’m not saying free = bad. On the contrary, I frequently use OSS(Open Source Software). I have an OpenBSD router and I wouldn’t have it any other way. I have a LAMP (Linux Apache MySQL PHP) server running certain custom Apps and I wouldn’t run them on anything else. I use VMWare on Ubuntu and I wouldn’t dream of running it on Windows. But when it comes to a domain controller, Samba has been a bit lacking. I hate to admit it, but Microsoft did a good job on Active Directory, and I’ve begrudged the fact that I can’t use it for some time.

But that’s all changing soon. According to the “WHATSNEW” doc in TP5, an alpha version of Samba 4 should be released in the next few months! Then comes BETA, and then eventually a stable release of Samba 4 with full AD support. I can’t wait. Until then, I’ll get everything I can out of Samba with OpenLDAP, but that day is coming!

Samba + LDAP

Tuesday, July 17th, 2007

I’m making some virtual machines in VMWare to load on my servers. I’m upgrading all the hardware and moving everything to virtual machines. We’ve been having some trouble with our network as the result of a crash a few months ago. Our server crashed when I was performing an upgrade and I had a terrible time with some kernel modules I needed to support our RAID controller. The fact of the matter is I got stressed and felt pressured for time and decided to implement Samba w/ LDAP on OpenBSD. I’d been using Samba for some time, but hadn’t used LDAP. I also hadn’t used OpenBSD as a Samba server before. What I discovered is that Samba + LDAP isn’t fully implemented in OpenBSD.

Anyway, the point is I need to do it all over and do it right this time. So I’ve been planning, and testing and this is what I got.

First of all, there are some great examples for setting up Samba at samba’s own website. Just go to http://us1.samba.org/samba/docs/man/Samba-Guide/. You can go there and learn all you need. Go through the examples and get your Samba/LDAP PDC all setup. Or you can cheat, like I did, with smbldap-installer. I thought I’d write an extensive HOWTO, but the truth is everything you need is at http://www.vcsvikings.org/docuwiki/cgi-bin/moin.cgi/FrontPage. You can get the files you need there, then follow the instructions in the wiki. In Ubuntu, all I had to do was download the script, untar it, then run it. It automagically downloaded all the files and dependencies I needed, asked me a few questions, and before I knew it I had a Samba/LDAP PDC installed and working. The same script is also used to configure a Samba/LDAP BDC. Could it be any easier?

Now I just need to setup all my users and we’re good to go.

iSCSI SAN

Thursday, June 7th, 2007

There’s been so much talk about SAN’s lately, and I knew my budget would never allow me to purchase one, so this week I built my very own iSCSI SAN.

I put together a system with an AMD Athlon64 X2 AM2 3800+ with 2GB DDR2 800 RAM, a 20GB IDE HDD for the OS and 4 250GB HDD I had lying around. Three of the 250GB HDD’s are IDE and the fourth is SATA. When my budget allows I intent to replace the IDE’s for SATA’s. I installed Ubuntu Server 7.04 on the 20GB HDD. Then installed iscsi-target, configured my LUN’s and all was done. For the moment I’m just using one of the 250GB HDD’s as a backup for our server, but now that I know how easy it was to setup, I’m going to think of some more creative ways to use my homemade SAN.

For those of you interested, here’s how I setup the software.

First download and install Ubuntu. It was pretty straightforward so I won’t get into that part of it. Once Ubuntu is installed get all the updates, including any kernel updates:

# sudo apt-get update
# sudo apt-get dist-upgrade
# sudo apt-get upgrade
Once all the updates are installed reboot. Now you need to install a few more packages:

# sudo apt-get install make
# sudo apt-get install libssl-dev
# sudo apt-get install linux-headers-`uname -r`
# sudo apt-get install gcc
Now make a symlink to your kernel source:

# sudo ln -s /usr/src/linux-headers-`uname -r` /usr/src/linux

This way make can find your kernel source files when you compile scsi-target without any other configuration from you.

Now download iscsi-target from http://sourceforge.net/project/showfiles.php?group_id=108475. Unzip and untar the file, the cd into the directory you extracted it to. Now:

# make
# sudo make install

If you don’t get any errors iscsi-target is installed. I did find one compatibility problem with the startup script with Ubuntu. To fix it edit /etc/init.d/iscsi-target by changing the first line from

#!/bin/sh

to

#!/bin/bash

No copy the ietd.conf file from the etc/ directory under the directory where you compiled iscsi-target to the systems /etc directory. You should read the man files and all associated documentation, but the only things you need to worry about to get up and running are the ‘Target’, ‘Lun 0 Path=’, and ‘Alias’ options. Configure these according to your system, then start up iscsi-target:

# sudo /etc/init.d/iscsi-target start

Now you just need to configure your iscsi initiators on whatever your want to use the iscsi drives on. I tested it in Windows and in Linux and it works beautifully. So far I’ve only tested it by making one HDD = one LUN, but it should be able to support different types of configurations such as RAID or file LUN’s, and there’s failover support as well. I’ll look into these some more and get the details back to you.

I’m just excited to have a 1TB homemade SAN to play with now.

OpenBSD/DG/Squid HowTo

Wednesday, June 6th, 2007

I’ve had several people ask me recently how to setup Dan’s Guardian (DG) with Squid as a transparent proxy. I’ve been using DG for a couple of years now and I’ve set it up for some others as well. I’ve always used OpenBSD as my OS of choice for my router/firewall/content filter(RFCF) because OpenBSD is the most secure Operating System in the world. “Only two remote holes in the default install, in more than 10 years!” It says so right on their website (http://www.openbsd.org). I was first turned on to OpenBSD by my good friend DarkUncle (http://darkuncle.net) who helped me setup my first OpenBSD RFCF with Squid and DG as an alternative to SonicWall.

 

I’ve run through this setup in a virtual machine and will make the VM available to anyone who wants it when this setup is finished here. I don’t suggest that you run your RFCF from the VM. It is only available for your reference. As far as hardware goes you don’t need much. We’re going to install OpenBSD without the X-Server, so it will run well even on older hardware. DG does need a little more to analyze all your traffic and filter it on the fly. I’ve run it on a PIII 700MHz with 128MB of RAM with a 40GB HDD without any problems. You could use a lot smaller hard drive without any problems. I’m currently only using 5GB of my HDD space and 4.4GB of that is Squid’s cache. The one thing you will need is 2 NIC’s. One NIC for your WAN and one for your LAN. If you are hosting any services such as a website or hosting your own email, I would also suggest setting up a DMZ using a third NIC. It makes configuring pf much easier.

 

We’ll start by installing OpenBSD. First you need to download the installation CD. I got the necessary ISO from ftp://ftp.openbsd.org/pub/OpenBSD/version/i386/. As of the writing of this document 4.1 was the latest release of OpenBSD. So I download ftp://ftp.openbsd.org/pub/OpenBSD/4.1/i386/cd41.iso, then make a CD from the ISO from your favorite CD burning software.

Let’s talk a minute about partitions. BSD partitions are a little different than linux partitions. You will use fdisk to create one BSD partition on your hard drive, then you’ll create BSD partitions inside that partition. For a more detailed discussion read http://en.wikipedia.org/wiki/BSD_disklabel. As far as the sizes of the partitions, the following is what I’ll setup on my VM with a 4GB HDD.

Partition

Size

Mount point

a

400M

/

d

200M

/tmp

e

1.5G

/usr

f

200M

/var

g

The rest

/var/squid

 

We don’t need a lot of space in / or /tmp. The /usr partition will be where most of your software is installed to, as well as the location of the ports is you choose to use them. On a larger drive I usually create other partitions for /usr/local (software installs to this directory), /usr/ports (for the ports tree) and /usr/src (for the kernel source). The /var partition will hold all our log files and /var/squid will hold squids cache which will become quite large. I usually create another partition for /home as well, but there’s not much space on this VM and users won’t actually be logging into this system so that’s not quite so important.

The following is my partition table on the RFCF I’m currently using:

Filesystem Size Used Avail Capacity Mounted on

/dev/wd0a 1006M 227M 730M 24% /

/dev/wd0d 502M 6.0K 477M 0% /tmp

/dev/wd0e 4.9G 13.0M 4.7G 0% /home

/dev/wd0f 1006M 835M 122M 87% /usr

/dev/wd0g 1006M 2.0K 956M 0% /usr/obj

/dev/wd0h 3.0G 43.2M 2.8G 2% /usr/local

/dev/wd0j 4.9G 121M 4.6G 3% /usr/ports

/dev/wd0i 4.9G 579M 4.1G 12% /usr/src

/dev/wd0k 24.6G 162M 23.2G 1% /var

/dev/wd0l 27.6G 4.4G 21.8G 17% /var/squid

 

Boot off the CD you made and let’s begin installing OpenBSD. For this tutorial I’ll display the prompt you are given in italics and your response in bold.

(I)nstall, (U)pgrade, or (S)hell? I

Terminal Type? [vt220] Hit Enter

kdb(8) mapping? (‘L’ for list) [none] us

Proceed with Install? [no] yes

Which one is the root disk? (or ‘done’) [wd0] hit Enter

Do you want to use *all* of wd0 for OpenBSD [no] yes

>d a

>a a

Offset: [63] Hit Enter

Size [8385867] 400M

Fs type: [4.2BSD] Hit Enter

Mount point: [none] /

>a d

Offset: [819504] Hit Enter

Size [7566426] 200M

Fs type: [4.2BSD] Hit Enter

Mount point: [none] /tmp

>a e

Offset: [1228752] Hit Enter

Size [7157178] 1.5G

Fs type: [4.2BSD] Hit Enter

Mount point: [none] /usr

>a f

Offset: [4374720] Hit Enter

Size [4011210] 200M

Fs type: [4.2BSD] Hit Enter

Mount point: [none] /var

>a g

Offset: [4783960] Hit Enter

Size [3601962] Hit Enter

Fs type: [4.2BSD] Hit Enter

Mount point: [none] /var/squid

>w

>q

Mount point for wd0d (size=204624k)? (or ‘none’ or ‘done’) [/tmp] done

Are you really sure that you’re ready to proceed? [no] yes

System hostname? (short form, e.g. ‘foo’) guardian

Configure the network? [yes] Hit Enter

Available interfaces are: pcn0 pcn1.

Which one do you wish to initialize? (or ‘done’) [pcn0] Type the name of the NIC you want to use, or if it is already selected just hit Enter

Symbolic (host) name for pcn0? [guardian] Hit Enter

Finish setting up the network based on your settings…

Password for root account? (will not echo) YOURPASSWORDHERE (p4ssw0rd in the VM)

Location of sets? (cd disk ftp http or ‘done’) [cd] ftp

HTTP/FTP proxy URL? (e.g. ‘http://proxy:8088’, or ‘none’) [none] Set for your network

Display the list of known ftp servers? [no} yes

Find an ftp server close to you

Server? (IP address, hostname, list$, ‘done’ or ‘?’) Type the list# of an ftp server close to you, I chose 67

Server? (IP address, hostname, list#, ‘done’ or ‘?’) [yourftpserverhere] Hit Enter

Does the server support passive mode ftp? [yes] Hit Enter

Server directory? [pub/OpenBSD/4.1/i386] Hit Enter

Login? [anonymous] Hit Enter

Set name? (or ‘done’) [bsd.mp] done

Ready to install sets? [yes] Hit Enter

Now wait for it to install. I chose to in stall only the default sets for security reasons. Keep in mind the default sets do NOT install X-Server. I manage my server via ssh so it’s not necessary. If you wish to install X-Server you should type ‘all’ at the ‘Set name?’ prompt(w/o the quotes), then type ‘done’ when all the sets are selected. Keep in mind that the claim on OpenBSD’s home page, “. “Only two remote holes in the default install, in more than 10 years!” refers only to the default installation. Installing more software increases the possibility of security holes.

If there are any errors during the install process chose another ftp server to install from. When the install is finished:

Location of sets? (cd disk ftp http or ‘done’) [done] Hit Enter

Start sshd(8) by default [yes] Hit Enter

Start ntpd(8) by default? [no] If you want ntpd running type ‘yes’ otherwise hit Enter

Do you expect to run the X Window System? [no] Hit Enter

Change the default console to com0 [no] Hit Enter

# halt

Congratulations, you’ve just installed OpenBSD. Now reboot and we’ll continue.

After you reboot you will need to login as root, then you should create a new user. This is the user you should login as most of the time. You should use sudo if you need to run anything as root. In the VM I created a user guardian with password gu4rdi4n. You will want to add this user to the wheel group, then modify /etc/sudoers and add the following line:

%wheel ALL=(ALL) ALL

This will allow the user guardian, and anyone else in the wheel group to issue commands with sudo.

Now we want to setup our network. I’m setting up the VM using the following network settings:

WAN (pcn0)

IP Address

NetMask

Gateway

DNS1

DNS2

10.1.1.15

255.255.255.0

10.1.1.1

10.1.1.1

10.1.1.2

LAN (pcn1)

IP Address

NetMask

192.168.1.1

255.255.255.0

 

First I’ll setup pcn0 by creating/editing /etc/hostname.pcn0 as follows:

inet 10.1.1.15 255.255.255.0 10.1.1.255 media \

mediaopt full-duplex description “external”

Now I’ll setup pcn1 by creating/editing /etc/hostname.pcn1 as follows:

inet 192.168.1.1 255.255.255.0 192.168.1.255 \

mediaopt full-duplex description “internal”

NOTE: pcn1 is Gigabit

Now let’s create/edit /etc/mygate:

10.1.1.1

I’m going to use this server as my DHCP server so edit /etc/dhcpd.conf:

 

# DHCP server options.

# See dhcpd.conf(5) and dhcpd(8) for more information.

#

# Network: 192.168.1.0/24

# Domain name: my.domain

# Name servers: 192.168.1.1, 10.1.1.1, 10.1.1.2

# Default router: 192.168.1.1

# Addresses: 192.168.1.100 – 192.168.1.250

#

shared-network LOCAL-NET {

option domain-name “my.domain”;

option domain-name-servers 192.168.1.1, 10.1.1.1, 10.1.1.2;

# 10.1.1.0/24 is for PC clients; add’l subnets to be added

subnet 192.168.1.0 netmask 255.0.0.0 {

deny bootp;

option routers 192.168.1.1;

range 192.168.1.100 192.168.1.250;

}

}

 

Now to get dhcpd to load on boot edit /etc/rc.conf. Change

dhcpd_flags=NO

To

dhcpd_flags=”pcn1”

 

Now reboot. After it reboots make certain you are online by pinging something like Google, then see if one of your workstations can successfully obtain dhcp info. Now let’s start installing software. First we’ll need to install squid as a transparent proxy. You can either get squid from ports or through pkg_add. Both procedures are described in detail at http://www.openbsd.org/faq/faq15.html. For simplicity I’m only going to work with pkg_add.

First we need to setup the PKG_PATH variable. Pick an ftp mirror close to you from the list at http://www.openbsd.org/ftp.html. I’m going to use the master site for simplicity. Then edit ~/.profile and add:

PKG_PATH=ftp://ftp.openbsd.org/pub/OpenBSD/4.1/packages/i386/

Export PKG_PATH

Now logout and log back in. You can find a list of packages to install at http://www.openbsd.org/4.1_packages/i386.html. There are four squid packages. There’s just plain squid, there’s squid configured as a transparent proxy, squid with snmp, and squid configured as a transparent proxy with snmp. We want to use squid as a transparent proxy, and you may want to use snmp so I’ll use squid-2.6.STABLE9-transparent-snmp.tgz. The command to install this package is:

# sudo pkg_add squid-2.6.STABLE9-transparent-snmp.tgz

 

Pkg_add will download and install all the files we need, then it gives you some tips on getting things going.

Please remember to initialize the cache by running “squid –z” before trying to run Squid for the first time.

You can also edit /etc/rc.local so that Squid is started automatically:

if [ -x /usr/local/sbin/squid ]; then

echo –n ‘squid’; /usr/local/sbin/squid

fi

 

Do as it says. Edit /etc/rc.local to add the lines above. Then run:

# sudo /usr/local/sbin/squid –z

 

Now let’s install DG. Download DG from one of the mirrors at http://dansguardian.org/?page=download2. We’re going to install from source. We’ll download the source using wget, so we’ll have to install wget first. So follow these steps:

# sudo pkg_add wget

# wget http://usmirror.dansguardian.org/downloads/2/Stable/DansGuardian-2.8.0.6.source.tar.gz

# tar xvzf DansGuardian-2.8.0.6.source.tar.gz

# cd DansGuardian-2.8.0.6

Read README and INSTALL. INSTALL tells us that BSD users need bash installed first, so:

# sudo pkg_add bash

# ./configure –cgidir=/var/www/cgi-bin/ \

–sysconfdir=/usr/local/etc/DG/ \

–sysvdir=/usr/local/etc/rc.d/ \

–bindir=/usr/sbin/ \

–mandir=/usr/share/man/

# make

# sudo make install

 

Now that DG is installed we need a blacklist for DG to work with. The maker of DG no longer keeps a blacklist, instead he has passed the torch to URLBlacklist. The provide a script that downloads the blacklist and updates DG automagically. So:

# wget http://urlblacklist.com/downloads/UpdateBL

Now the script needs updates to work with OpenBSD. So change the first line from:

#!/bin/bash

To

#!/bin/sh

You will also need to read through the script and make a few changes for your environment. First change the BL_URL variable to point to the biglist. (It’s all in the script.) Now change BL_INFO_PATH, DB_PATH, and DG_PATH. If you’ve followed this tutorial just add /usr/local to the beginning of the first to, and change the last from /usr/sbin to /usr/local/sbin. I also had to comment out the http_proxy line.

Please note that the blacklist is NOT free. You may download it once to try, but to keep it updated you need a subscription. Go to http://urlblacklist.com for more info. A once per month update is $70/year.

Now move UpdateBL to a central location:

# mv ~/UpdateBL /usr/bin/

And change permissions:

# chmod 777 /usr/bin/UpdateBL

The run the script

# sudo mkdir /usr/local/etc/dansguardian/blacklists

# sudo UpdateBL

You will need to setup a cron job to regularly update the blacklist based on which subscription you choose.

# su

# crontab –e

And add:

0 0 1 * * /usr/bin/UpdateBL

This will run the update script on the 1st of every month. Then add:

0 0 * * 6 /usr/local/etc/dansguardian/logrotation

This will run the logrotation script every Saturday.

Now let’s finish setting up DG. Edit /usr/local/etc/dansguardian/dansguardian.conf. Change the “accessdeniedaddress” to the IP address of the server running DG.

Now let’s set DG to load when the server starts by adding the following to /etc/rc.local:

# Dan’s Guardian

if [ -x /usr/sbin/dansguardian ]; then

echo -n ‘ dansguardian’; /usr/sbin/dansguardian >/dev/null

fi

 

Now let’s run a quick test. As root run:

# /usr/local/sbin/squid

# /usr/sbin/dansguardian

If you get no errors, everything is working!! Otherwise check the logs to see why things may not be working.

Now for the final step we need to configure pf which is OpenBSD’s packet filter. Edit /etc/pf.conf to look like the following:

 

# $OpenBSD: pf.conf,v 1.34 2007/02/24 19:30:59 millert Exp $

#

# See pf.conf(5) and /usr/share/pf for syntax and examples.

# Remember to set net.inet.ip.forwarding=1 and/or net.inet6.ip6.forwarding=1

# in /etc/sysctl.conf if packets are to be forwarded between interfaces.

ext_if=”pcn0″

int_if=”pcn1″

#table persist

set skip on lo

scrub in

# needed for ftp-proxy

nat-anchor “ftp-proxy/*”

rdr-anchor “ftp-proxy/*”

# setup NAT

nat on $ext_if from !($ext_if) -> ($ext_if:0)

# redirect ftp traffic to ftp-proxy

rdr pass on $int_if proto tcp to port ftp -> 127.0.0.1 port 8021

# redirect www traffic to DansGuardian; change to 3128 to bypass DG and

# redirect directly to squid

rdr pass on $int_if proto tcp to port www -> 127.0.0.1 port 8080

#no rdr on $ext_if proto tcp from to any port smtp

#rdr pass on $ext_if proto tcp from any to any port smtp \

# -> 127.0.0.1 port spamd

# needed for ftp-proxy

#anchor “ftp-proxy/*”

# Block all incoming traffic

block in

# Let everything go out for now

pass out

# Allow traffic from internal NET

pass quick on $int_if no state

antispoof quick for { lo $int_if }

# Allow external ssh

pass in on $ext_if proto tcp to ($ext_if) port ssh

#pass in log on $ext_if proto tcp to ($ext_if) port smtp

#pass out log on $ext_if proto tcp from ($ext_if) to port smtp

Now start pf by running:

# pfctl –f /etc/pf.conf

If you get no errors all is well, otherwise the error should tell you where your problem is. Now we need to configure ftp-proxy and pf to load on boot. Edit /etc/rc.conf so that the lines that read:

pf=NO

ftpproxy_flags=NO

Now reads:

pf=YES

ftpproxy_flags=

 

Finally we need to set the kernel option net.inet.ip.forward to ‘1? by un-commenting the appropriate line in /etc/sysctl.conf.

Now reboot, and you should be 100% functional. If you wish to tweak your filtering settings edit the files in /usr/local/etc/dansguardian/. DG log files can be found in /var/log/dansguardian. I normally use grep to browse the logs, but if you prefer a gui interface you can install Webmin(http://www.webmin.com). There is a DG module for Webmin(http://sourceforge.net/projects/dgwebminmodule/) that makes administering DG very simple, though as of the writing of this tutorial the latest version of DG wasn’t supported yet. So if you wish to use it you will need to install version 2.8 of DG. I’ve setup the latest DG and used the default Webmin modules to make things easier for a fellow admin. Te LogViewer module can be configured to display DG logs, and you can use the File Explorer to browse and edit the config files. You can find some more tutorials at http://dansguardian.org/?page=documentation for other OS’s. There are also several add-ons available at http://dansguardian.org/?page=extras. I’ll write another tutorial using a Linux distro at some point in the future.

 

…bamed