1. Summary
  2. Files
  3. Support
  4. Report Spam
  5. Create account
  6. Log in

VirtualBox FreeBSD Dspam

From dspam

Jump to: navigation, search

Written by Paul Cockings for the Dspam Project June 2009

Contents

Introduction

This is an attempt to create a how-to style document, its my first so hopefully someone will find it useful. I intend to walk you through how to make a Dspam powered antispam gateway filtering box using the latest latest Dspam GIT code (currently about to turn 3.9.0 Alpha) I'll assume you have some skills with *nix boxes and hopefully you have a keen interest to learn and contribute to the the excellent Dspam project.

The Aim

An antispam filtering box that we'll receive smtp connections, filter the mail and pass on to a mail store. The box is just for filtering, not storing the mail. Perfect for placing between an inbound smtp feed and an exchange server!

The recipe

To save electric, we'll be using a virtual machine. My choice for this is Windows XP as the host with VirtualBox running FreeBSD as the Guest OS

  • FreeBSD 7.2 x86 (32bit)
  • Dspam from source
  • Postfix 2.6.2
  • MySQL server 5.1

Prepare the workspace

Install VirtualBox

Note: You really want to be using a dual core machine with lots of ram for this. Anything less than a P4-3.4HT and 2Gb Ram will be slow.
Alternativity, try this setup on real hardware, a P4-1.8 with 512Mb will be fine for testing (obviously you miss steps 1 & 2)

  • 1. Download VirtualBox and Install
  • 2. Create a new virtual machine
    • select OS type as BSD/FreeBSD
    • Base memory 1024Mb (depending on your hardware, but min. 512Mb)
    • New virtual disk suggest 8Gb to start (place on separate physical disk/controller if you have one to hand)
    • Use a Bridged Ethernet connection


Install FreeBSD

Note: You can learn much by reading the FreeBSD handbook http://www.freebsd.org/doc/en/books/handbook/index.html

  • 1. Download the current release, remember to download from a local mirror (you only need the ISO of cd1)
  • 2. Start you virtual machine and select the boot media as CD/DVD, from Image file (select 7.2-RELAESE-i386-disc1.iso)
  • 3. Let the machine boot, you'll see the 10second count down, then FreeBSD will boot to a ncurses country selection screen
  • 4. I'm selecting: 231 - United Kingdom > Next > The UK ISO > Next
  • 5. Then you'll arrive at the sysinstall Main Menu. Select 'Standard'
  • 6. Continue past the fdisk warning
  • 7. Black screen > Select A for Use entire disk, then Q to finish (don't worry any other options yet)
  • 8. Boot manager selection - Choose 'Standard' > [OK]
  • 9. BSD Partition message > [OK]
  • 10. Black screen, press 'A' for Auto defaults

On my setup this creates the following:

/ 396MB
swap 1164MB
/var 620MB
/tmp 339MB
/usr 5672MB

!!Note: this layout is not ideal for production use, but should be ok for our test box!!

  • 11. press 'Q' to finish
  • 12. Choose Installation Media: Select 1. CD/DVD
  • 13. [YES] to the warning  !Note: this is wiping clean the virtual harddisk, not your physical harddrive!
  • 14. Lots of installation messages, hopefully ending with 'Congratulations!' [OK]
  • 15. Would you like to configure any Ethernet [YES]
  • 16. Select em0 (Intel PRO/1000) [OK]
  • 17. IPv6 = NO > DHCP = YES
  • 18. Grey screen:
    • Host: dspam
    • Domain: test.local
    • IP/DNS/NETMSK should all be automatic [OK]
  • 19.More configuration settings:
    • Do you want this machine to function as a network gateway = NO
    • Configure inetd = NO
    • Enable SSH login = YES
    • Anonymous FTP = NO
    • NFS server = NO
    • NFS Client = NO
    • Customise console = NO
    • Time time zone = YES
      • CMOS Clock set to UTC = NO
      • Select 8 (europe)
      • Select 48 (UK)
      • Does BST look ok = YES
    • Would you like to enable linux binary compatibility = NO
    • Does system have mouse = NO
    • Browse package collection = NO
    • would you like to add user accounts = NO
    • Set root password [OK]
    • Visit general option = NO
  • 20. Returned back to the sysinstall menu. Choose 'X' Exit install
  • 21. Are you sure to exit = Yes
  • 22. Once back to the Sun xVM Bios screen, stop the VM.
  • 23. Open the VM setting, select CD/DVD-ROM section and untick 'Mount CD/DVD Drive', [OK] (note there are faster ways to do this, i'll let you discover them)
  • 24. Now start the VM, let the 10second timer count down (option1) and the system will boot
  • 25. You can login as root with the password you typed in during step 19


Install OS tools and configure

Note: this section is based on my preferences, you don't need to follow 100%

  • 1. Install the Midnight Commander - I've come from a windows background and just love this file manager/file editor
    • pkg_add -r mc
    • building from source is a pain with no advantage for this package. This command will fetch a pre compiled version of the package and install it to the system. This is also good to test for internet connection etc
    • Once installed type 'exit' to exit your session, then log back in again as root
    • type 'mc' [enter] and your have the midnight commander ready (hit F10 to exit)
  • 2. Download and install ports tree (internet connection must be working, about 58MB to download)
    • 'portsnap fetch'
    • 'portsnap extract'
  • 3. Install better shell
    • cd /usr/ports/shells/bash
    • make && make install
    • chsh -s /usr/local/bin/bash
    • exit, then re-log in and you'll be using the bash shell
  • 4. Open up SSH root login (not for production servers)
    • mcedit /etc/ssh/sshd_config
    • Line 47: change to: PermitRootLogin yes
    • F2 (save), F10(exit)
    • /etc/rc.d/sshd restart
  • 5. install git tools
    • pkg_add -r git
  • 6. install mysql server
    • pkg_add -r mysql51-server
    • echo mysql_enable="yes" >> /etc/rc.conf
    • /usr/local/etc/rc.d/mysql-server start
    • /usr/local/etc/rc.d/mysql-server status
    • should output something like: mysql is running as pid xxx.
  • 7. replace sendmail with postfix (we'll compile this one from source) 4Mb
    • cd /usr/ports/mail/postfix
    • make config
    • select pcre, mysql, [OK]
    • make && make install
    • You need user "postfix" added to group "mail". Would you like me to add it [y]? [ENTER]
    • Would you like to activate Postfix in /etc/mail/mailer.conf [n]? y [ENTER]
    • mcedit /etc/rc.conf
    • add these lines to the end of file
      • postfix_enable="YES"
      • sendmail_enable="NO"
      • sendmail_submit_enable="NO"
      • sendmail_outbound_enable="NO"
      • sendmail_msp_queue_enable="NO"
      • daily_clean_hoststat_enable="NO"
      • daily_status_mail_rejects_enable="NO"
      • daily_status_include_submit_mailq="NO"
      • daily_submit_queuerun="NO"
    • Check these details carefully!
    • F2 (save), F10 (exit)
    • suggest a reboot


End of section checks

  1. Reboot
  2. can login as root
  3. /usr/local/etc/rc.d/mysql-server status = mysql is running as pid xxx.
  4. /usr/local/etc/rc.d/postfix status = postfix is running as pid xxx.
  5. tail -n 100 /var/log/messages - check for errors
  6. tail -n 100 /var/log/maillog - check for errors


Install DSPAM

download the 3.9.0 tarball from the website extract

As the port seems to be broken, lets build it manually


./configure --sysconfdir=/usr/local/etc --with-logdir=/var/log/dspam --with-dspam-home=/var/db/dspam --with-dspam-home-owner=dspam --with-dspam-home-group=mail --with-dspam-home-mode=0770 --with-dspam-owner=root --with-dspam-group=mail --enable-syslog --enable-debug --enable-domain-scale --enable-preferences-extension --enable-daemon --enable-clamav --with-mysql-includes=/usr/local/include/mysql --with-mysql-libraries=/usr/local/lib/mysql --with-storage-driver=mysql_drv --enable-virtual-users --enable-long-usernames --with-dspam-mode=4510 --prefix=/usr/local --mandir=/usr/local/man --infodir=/usr/local/info/ --build=i386-portbld-freebsd6.2

make

make install



NOTE: This is work in progress......

Next steps

  1. Add SQL tables
  2. Configure dspam
  3. Configure postfix
  4. Configure webgui
  5. Setup some users
  6. Send some test emails
Personal tools