Intrusion Detection: Snort, Base, MySQL, and Apache2 On Ubuntu 7.10 (Gutsy Gibbon) (Updated) 

This tutorial is based on another howto written by DevilMan, however I didn't like the idea of manually compiling every package or the use of a GUI to get the software installed. This howto will work on a Gutsy Server or Gutsy desktop. With that said some of this howto is a direct copy from the original.

In this tutorial I will describe how to install and configure Snort (an intrusion detection system (IDS)) from source, BASE (Basic Analysis and Security Engine), MySQL, and Apache2 on Ubuntu 7.10 (Gutsy Gibbon). Snort will assist you in monitoring your network and alert you about possible threats. Snort will output its log files to a MySQL database which BASE will use to display a graphical interface in a web browser.


1. Gain root privileges

It is easiest to do this install as root user.

sudo su -


2. Install some packages

The following will install all the required packages to make this setup work:

apt-get install libpcap0.8-dev libmysqlclient15-dev mysql-client-5.0 mysql-server-5.0 bison flex apache2 libapache2-mod-php5 php5-gd php5-mysql libphp-adodb php-pear libc6-dev g++ gcc pcregrep libpcre3-dev


3. Get and compile snort

The Snort package in the Gutsy repo's are out of date. So I prefered to download the most current and install that. This is the only thing we will compile from scratch.

The latest version of snort at the time of writing is

First let's go to a working directory:

cd /usr/src/

Open a web browser and navigate to right click on the most recent release and copy link location.


a. Download snort and snort rules


There are a couple options for rules. The following will download the public rules, however with a quick registration at the snort site you can get more current rules. Your choice but the next command is run the same way with the appropriate URL:



b. Unpack and get them ready for compile

tar zxvf snort-
cd snort-
tar zxvf ../snortrules-pr-2.4.tar.gz


c. Now compile them

./configure -enable-dynamicplugin --with-mysql
make install

Keep this directory handy as you can simply run

make uninstall

To uninstall snort later if you choose


d. Move things into position

We now need to move the rules and config for snort into position

mkdir /etc/snort /etc/snort/rules /var/log/snort
cd /usr/src/snort-
cp * /etc/snort/
cd ../rules
cp * /etc/snort/rules


4. Configure Snort

We need to modify the snort.conf file to suite our needs.

Open /etc/snort/snort.conf with your favorite text editor (nano, vi, vim, etc.).

# vi /etc/snort/snort.conf

Change "var HOME_NET any" to "var HOME_NET" (your home network may differ from
Change "var EXTERNAL_NET any" to "var EXTERNAL_NET !$HOME_NET" (this is stating everything except HOME_NET is external)
Change "var RULE_PATE ../rules" to "var RULE_PATH /etc/snort/rules"

Scroll down the list to the section with "# output database: log, mysql, user=", remove the "#" from in front of this line.
Change the "user=root" to "user=snort", change the "password=password" to "password=snort_password", "dbname=snort"
Make note of the username, password, and dbname. You will need this information when we set up the Mysql db.
Save and quit.

Change permissions on the conf file to keep things secure (thanks rojo): 

# chmod 600 /etc/snort/snort.conf

5. Setup the Mysql database.

Log into the mysql server.

# mysql -u root -p

Create the snort database. Make sure you change the 'snort_password' to something else!

mysql> create database snort;
grant all privileges on snort.* to 'snort'@'localhost' identified by 'snort_password'; mysql> exit

We will use the snort schema for the layout of the database.

# mysql -D snort -u snort -p < /usr/src/snort-

NOTE: Use your snort DB user password when prompted.


6. Time to test Snort

In the terminal type:

# snort -c /etc/snort/snort.conf

If everything went well you should see an ascii pig.

To end the test hit ctrl + c.

NOTE: If you get errors you may want to try commenting out lines 97,98 and 452 of /etc/snort/rules/web-misc.rules. This was an issue in the past but doesn't seem to be anymore.


7. Get and install BASE

Open a web browser and go to

Click on download then right click on the newest tar.gz package and select copy link (at the time of writing this is base-1.3.9).

In the terminal type:


Now go to your web document root (by default this is /var/www), unpack the tarball and set the permissions needed to configure BASE:

cd /var/www/
tar zxvf ~/base-1.3.9.tar.gz
cd ..
chmod 757 base-1.3.9

We want to make sure that a couple of Pear modules are activated:

pear install Image_Color
pear install Image_Canvas-alpha
pear install Image_Graph-alpha


8. Set up BASE

Open a web browser and navigate to http://YOUR.IP.ADDRESS/base-1.3.9/setup.

Click continue on the first page.

  • Step 1 of 5: Enter the path to ADODB.
    This is /usr/share/php/adodb.
  • Step 2 of 5:
    Database type = MySQL, Database name = snort, Database Host = localhost, Database username = snort, Database Password = snort_password
  • Step 3 of 5: If you want to use authentication enter a username and password here and check the box.
  • Step 4 of 5: Click on Create BASE AG.
  • Step 5 of 5: once step 4 is done at the bottom click on Now continue to step 5.

Bookmark this page.

Change the permissions back on the /var/www/base-1.3.9 folder.

# chmod 755 /var/www/base-1.3.9


We are done. Congrats!!!

To start Snort in the terminal type (make sure you change eth0 to the right interface for your machine:

# snort -c /etc/snort/snort.conf -i eth0 -D

This starts snort using eth0 interface in a daemon mode.  You can add this to your /etc/rc.local file so that it starts after a reboot.

To make sure it is running you can check with the following command:

# ps aux | grep snort

If it's running you will see an entry similar to snort -c /etc/snort/snort.conf -i eth0 -D.

If you would like to learn how to write your own Snort rules there is a guide at
Good luck.

Share this page:

9 Comment(s)

Add comment


From: Andrew at: 2009-05-08 00:21:41

This How-To works with BASE 1.4.2, Ubuntu 9.04, and Snort

 Thanks so much.



From: at: 2008-01-17 16:26:41

There are a few changes I'd recommend.

  • libpcre3-dev is also required, but is not automatically installed with the other packages (at least on Debian Etch, anyway).
  • Step 4, you should add "chmod 600 /etc/snort/snort.conf" since snort.conf contains a plaintext password. 
  • Step 7, the second code block needs some line breaks.
  • A note to add "snort -c /etc/snort/snort.conf -i eth0 -D" to /etc/rc.local couldn't hurt either.

Otherwise, these instructions test successfully on Debian Etch as well.  Very nice job.

From: at: 2008-01-23 15:11:53

Thanks Rojo.  I've added your recommendations to the howto.  I will leave the oinkmaster mini-howto as a comment for those that want it... :)

From: Angry at: 2008-11-12 03:53:03

Just wanted to thank you for the tutorial.  It didn't work until I did

pear install Mail

pear install Mail_Mime

per the user forums.  Before I did this, I received several errors on step 4 of the BASE web-based configuration.

From: at: 2008-01-17 18:06:37

Install and configure Oinkmaster to update snort's ruleset daily.

apt-get install oinkmaster

modify /etc/oinkmaster.conf so that:

url =<your registered key>/snortrules-snapshot-CURRENT.tar.gz


groupadd snort
useradd -g snort snort -s /bin/false
chmod 640 /etc/oinktmaster.conf
chown root:snort /etc/oinkmaster.conf
nano -w /usr/local/bin/oinkdaily

In /usr/local/bin/oinkdaily, include the following, uncommenting the appropriate line:


## if you have "mail" installed, uncomment this to have oinkmaster mail you reports:
# /usr/sbin/oinkmaster -C /etc/oinkmaster.conf -o /etc/snort/rules 2>&1 | mail -s "oinkmaster" your@email.address

## otherwise, use this one:
# /usr/sbin/oinkmaster -C /etc/oinkmaster.conf -o /etc/snort/rules >/dev/null 2>&1


chmod 700 /usr/local/bin/oinkdaily
chown -R snort:snort /usr/local/bin/oinkdaily /etc/snort/rules
crontab -u snort -e

In user snort's crontab, to launch the update on the 30th minute of the 5th hour of every day, add the following:

30 5 * * *     /usr/local/bin/oinkdaily

But you should randomize those times (for instance, 2:28 or 4:37 or 6:04) to reduce the impact on's servers.

From: at: 2008-03-02 05:39:37

Cheers for the great tutorial you made.

Just thought to add, that if people run into trouble running snort in daemonmode(like me), and dont see any details in /var/log/snort/alert.

You can run the same command without  -D and snort will report what went wrong!!

snort -c /etc/snort/snort.conf -i eth0

 In my case i made an error in the config for the rule_path. And when u can see whats wrong, u can fix it!

 Thanks again volksman.


From: Swetha at: 2008-11-14 01:34:42

swetharaghav@Raghavendra-PC:~$ sudo apt-get install libpcap0.8-dev libmysqlclient15-dev mysql-client-5.0 mysql-server-5.0 bison flex apache2 libapache2-mod-php5 php5-gd php5-mysql libphp-adodb php-pear libc6-dev g++ gcc pcregrep libpcre3-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Couldn't find package libpcap0.8-dev
swetharaghav@Raghavendra-PC:~$ sudo apt-get install libpcap0.8-dev libmysqlclient15-dev mysql-client-5.0 mysql-server-5.0 bison flex apache2 libapache2-mod-php5 php5-gd php5-mysql libphp-adodb php-pear libc6-dev g++ gcc pcregrep libpcre3-dev


Can someone please tell me what the error is??? 

From: AMOR at: 2009-01-11 15:04:31

i want just to thank you for the article that you posted about the intrusion detection,it helps me very well to install snort,there are some problems but i likes what i got so far.

Oueriach Amor

From: Robert at: 2009-11-24 09:37:03

Thanx for the tutorial!

I did install snort, base, and mysql edhe everything is running...but nothing is being logged...base or to the the /var/log/snort!!

could anybody help me with this plz