Setup Sendmail Smart Relay in FreeBSD

It’s good that to route all your outgoing email to a relay server for centralize management. Compiling Sendmail’s Smart Relay options in FreeBSD is slightly different from Linux machine. But it’s fairly easy to do so. Just follow the steps below, and I assume you already have your own email relay server to relay to.

Go to /etc/mail
run “make” command for the first time to generate “yourdomain”.cf and “yourdomain”.submit.cf / “yourdomain”.mc and “yourdomain”.submit.mc file


shell> cd /etc/mail
shell> make
shell> cp freebsd.mc "yourhostname".mc
/usr/bin/m4 -D_CF_DIR_=/usr/share/sendmail/cf/   /usr/share/sendmail/cf/m4/cf.m4 "yourhostname".mc > "yourhostname".cf
cp freebsd.submit.mc "yourhostname".submit.mc
/usr/bin/m4 -D_CF_DIR_=/usr/share/sendmail/cf/   /usr/share/sendmail/cf/m4/cf.m4 "yourhostname".submit.mc > "yourhostname"submit.cf

After mc and mf files have generated. Edit .mc file, look for line below. Change the SMART HOST to your email server’s hostname. It must be hostname and you CAN’T configure IP Address for SMART HOST.


shell> vi "yourdomain".mc

dnl define(`SMART_HOST', `your.isp.mail.server')
define(`SMART_HOST', `relay.server.hostname')

Next copy “define(`SMART_HOST’, `relay.server.hostname’)” and paste it in “yourhostname”.submit.mc. It must be placed before the line of “msp” feature.


define(`SMART_HOST', `relay.server.hostname')
FEATURE(`msp', `[127.0.0.1]')dnl

After configuration has been made, now run "make install" to generate the cf file and replace sendmail.cf and submit.cf


shell> make install
shell> /usr/bin/m4 -D_CF_DIR_=/usr/share/sendmail/cf/   /usr/share/sendmail/cf/m4/cf.m4 "yourhostname".mc >  "yourhostname".cf
install -m 444  "yourhostname".cf /etc/mail/sendmail.cf
/usr/bin/m4 -D_CF_DIR_=/usr/share/sendmail/cf/   /usr/share/sendmail/cf/m4/cf.m4  "yourhostname".submit.mc >  "yourhostname".submit.cf
install -m 444 iyot.time.com.my.submit.cf /etc/mail/submit.cf

You are basically done, now. Just restart sendmail services.


shell> /etc/rc.d/sendmail restart
shell> Cannot 'restart' sendmail. Set sendmail_enable to YES in /etc/rc.conf or use 'onerestart' instead of 'restart'.
Stopping sendmail_submit.
Waiting for PIDS: 64903.

Ignore the line to change sendmail_enable to YES if your server just do email submit and it doesn't act as incoming email.

ClamAV Signal 11 Core Dumped on FreeBSD 8.1

Just upgraded to latest ClamAV after freebsd-update, unfortunately ClamAV was unable to start due to signal 11 core dumped. What I did was move the file in /usr/local/lib/compat/pkg/libclam* to other folder and start again, it works.

For the bugs info, visit https://wwws.clamav.net/bugzilla/show_bug.cgi?id=2066

Building PHP Web App in 15 minutes with Symfony Framework

Last year, I gave a talk at Coscup 2009, an Open Source Conference in Taipei on PHP web development with Symfony Framework.

You might interested to know what Symfony can help on rapid development on PHP, and here are the videos. Thanks to Coscup fellow and they are really helpful. Sadly can’t be there this year for Coscup 2010.

How to Install Cacti Plugin Architecture

Cacti Plugin Architecture allow you to run useful monitoring plugins on Cacti. There are several good plugins like Thold, Aggregator and Weathermap which give you comprehensive network device monitoring.

There are a few steps involve In order to install Cacti Plugin Architecture. First we will need to backup current cacti files, and overwrite the files for Cacti Plugin Architecture and lastly to make some changes on configuration files in order to activate Cacti Plugin Architecture.

Installing Cacti Plugin Architecture

Cacti Plugin Architecture can be downloaded at Cacti Users website. The demo I am going to show is to download Cacti Plugin Architecture version 2.8 on Cacti version 0.8.7g.

Before installing Cacti Plugin Architecture, lets make a backup copy of your cacti files, in case something goes wrong, you can roll back to the original files. During the backup, we are going to exclude rra and log directory.

First change directory to the directory which located Cacti files, in FreeBSD would be /usr/local/share


shell> cd /usr/local/share
shell> tar -zcf cacti.backup.tar.gz --exclude=rra --exclude=log cacti

After backup, it’s now safe to replace your cacti files with cacti architecture files. First untar Cacti Plugin Architecture which you have downloaded earlier.


shell> tar -zxf cacti-plugin-0.8.7g-PA-v2.8.tar.gz

After untar-ed cd to plugin architecture folder and edit config.php.dist file with your mysql database credentials. Follow with rename the file to config.php


shell> tar -zxf cacti-plugin-0.8.7g-PA-v2.8.tar.gz
shell> cd cacti-plugin-arch
shell> vi include/config.php.dist
shell> mv include/config.php.dist include/config.php

In include/global.php, edit MySQL database credentials as well.


shell> vi include/global.php

Next, create the database table which required by Plugin Architecture. The file is located at cacti-plugin-arch directory with file name pa.sql.


shell> mysql -u username -p cacti < pa.sql

Now, it's all good, copy all the files into cacti directory. You cacti directory might be different from mine directory path.


shell> cp -rf * /usr/local/share/cacti/

The installation for Cacti Plugin Architecture is done. In order to access to Plugin Setting. Log on to Cacti, go to User Management, click on Admin, check Plugin Management on realm management and Save.

You should see Plugin Management on your left menu bar. On the next post we will go through the plugins for Cacti Plugin Architecture.

How to Check Linux Version and Distro

Who run more than 10 Linux servers with different version of Linux Distro? We all know there are many type of Linux distro such as Ubuntu, Centos, Gentoo, Fedora, debian, OpenSUSE and etc. Every single distro runs on different version and etc. Sometime I am having problem to remember what Linux distro is running on my DNS server or Mail Server, and what Linux version is it on now. There are two methods to find linux version on your server.

To check Linux distro on your server


shell> cat /etc/issue

To check Linux Version and distro on your server


shell> cat /etc/*-release