Category Archives: FreeBSD

Bind9: Master Only

Configuration for a master only DNS server.

1. WILL NOT answer queries
2. WILL NOT forward queries
3. WILL NOT perform recursion
4. WILL allow transfers from specified slaves

Zone and configuration files are backed up disk to disk via rsync.

Single point editing of our name space.

Single point of failure. If server is lost, updates to DNS cannot be made until another master is brought online.

options {
directory “/etc”;
pid-file “/var/run/named.pid”;
version “Windows 3.11”;
allow-query {“none”; };
allow-recursion {“none”; };
notify yes;
also-notify {
IPn.IPn.IPn.IPn;
};
allow-transfer {
IPn.IPn.IPn.IPn;
};
};

zone “my.hosts.net” {
type master;
file “/etc/my.hosts.net”;
};

Spam Bashing

We finally have our spam filtering back in place at kulish.com. We’ve set it to a semi-aggressive filter where pretty much every incoming email is marked with a spam score.

We’re using the postfix+amavis+clamd+spamassassin setup.

While we’ve been doing without it for a few months (using client side stuff until I found time), I still don’t remember it working this well on the last server install.

Here’s a wopper of an email, just after the installation and testing were completed. The receiving parties and server names have been sanitized to protect the marginally innocent (**PROTECTED**).

From ***PRO@TECTED***.com Tue Feb 14 23:02:47 2006
Return-Path:
Delivered-To: spam-quarantine
X-Envelope-From:
X-Envelope-To: **PROTECTED**
X-Quarantine-Id:
Received: from lh (unknown [61.130.156.43])
by **PROTECTED** (Postfix) with SMTP id D90164B92A;
Tue, 14 Feb 2006 23:02:35 -0600 (CST)
Received: from 61.130.156.43 (HELO localhost.localdomain) (61.130.156.43)
by 61.130.156.43 with SMTP; Wed, 15 Feb 2006 07:06:05 +0200
Message-Id:

Simple MySQL Backup Script

Below is a simple database backup script to use with MySQL.

#!/usr/bin/perl -w

use strict;

# Backup – Script used to backup MySQL databases to an NFS share.
# VERSION: 1.2
# DATE: 12152005
# AUTHOR: packetmad

# This is a Freebsd 4.x-centric script. It may run on other
# versions of Freebsd, or any other BSD for that matter, but I
# wrote it on a Freebsd 4.7 system. It’s not even guaranteed
# to run on that.

# Speaking of guarantees, warranties, etc., there ain’t one, so
# don’t even try. :P
# I am not responsible for the output of this script, nor am I
# responsible for any damage or data loss as a result of using
# this script. In short, I am not responsible for anything
# regarding this script.
# Furthermore, I am not responsible if this script causes
# Your dog to die, your wife to leave you, or
# your truck to break down.
# I am releasing this script under the conventions of the BSD
# license. You can use it, modify it, sleep with it, or
# whatever. If you do find this script useful or have
# suggestions on a better way to do some things contained here
# in, I welcome all correspondence.
# The latest version of this script can be obtained at:
# http://tech.kulish.com

# USE THIS SCRIPT AT YOUR OWN RISK!!!!!!!!!!!!!!!!!!

# Change Log
# v1.1
# Date: 11302002
# Initial Release, absolutely BUG FREE! :)
# v1.2
# Date: 12152005
# Added compression functionality
# Added naming of backup files by date
# Changed longterm storeage directory for 1back to store1

###
# Declare variables and arrays.
###

my (
$bdir, $sysname, $logfile, %databases, $key, $database, $rightnow
);

$bdir = ‘/databases/’;
chomp ( $sysname = `uname -n` );
chomp ( $rightnow = `date +%m%d%G%H%M` );
#print $rightnow;
# Databases we want to backup and associated archive names.
# Database => sql file pairs.

%databases = (‘testdb1’ => ‘testdb1.sql’,
‘testdb2’ => ‘testdb2.sql’);

###
# Backup Section
###
foreach $key (sort keys %databases) {
$database = $databases{$key};
`mysqldump -uUSERNAME -pPASSWORD $key >> $bdir$sysname/$database`;}

###
# Compression Functionality
###

foreach $key (sort keys %databases) {
$database = $databases{$key};
`gzip -c $bdir$sysname/$database > $bdir$sysname/$rightnow$database.gz`;}

# scp them to the fileshare
#`scp $bdir$sysname/*.gz USERNAME\@SERVER:databases`;

###
# Clean backup dir
###

`rm -rf $bdir$sysname/*.sql`;
`mv $bdir$sysname/*.gz $bdir$sysname/store1`;

STSE Supercluster

I’ve spent the last few months picking at a FreeBSD clustering project. Well, with some help from BSDHound and the Central Iowa Linux Users Group (CIALUG), it’s finally complete.

I clustered 4 Pentium 133s running FreeBSD 5.1-Release using LAM-MPI for the messaging interface and Ganglia for the monitoring. You can view the statistics here, but you must be registered and signed-in to do so (the pages are fairly graphic intensive).

I believe there will be a clustering How-To posted to BSDHound.com in the future, and if it is, I will be sure to post and update here.

Mounting Jumpdrives in FreeBSD

After my fiasco trying to get FBSD to auto mount when the jumpdrive was inserted, I ended up just creating a little perl script to take care of it for now (being finals week and all). It’s not much and does absolutely no error checking, but if anyone has any suggestions, they are more than welcome.

Keep in mind, you must have the proper settings active in your kernel for this to work.

Here it is:

#!/usr/bin/perl -w

use strict;

# If no arguments are given, print a brief help message
if (!defined($ARGV[0]))
{
print “\n”;
print “Help:\n”;
print “Lexar Jumpdrive mounting script\n”;
print “\n”;
print “You must provide one of the following arguments:\n”;
print “m Mounts the Jumpdrive.\n”;
print “u UnMounts the Jumpdrive.\n”;
print “\n”;
print “Example: lexar m\n”;
print “\n”;
}

# m mounts the jumpdrive
elsif ($ARGV[0] eq “m”)
{
# mounting the jumpdrive at /lexar
# this can be set to whatever you like
system “/sbin/mount -t msdos /dev/da0s1 /lexar”;
print “Jumpdrive mounted at /lexar.\n”;
}

elsif ($ARGV[0] eq “u”)
{
# umounts the jumpdrive
system “/sbin/umount /lexar”;
print “Jumpdrive unmounted.\n”;
}