******************************************************************************************************************
*** Qmail Installation howto on Ubuntu Server (tested on Ubuntu Server Edition 8.10/9.04) #
******************************************************************************************************************
Hi, I am rkarim1981@gmail.com
What I have done in this howto ...
I have googled a lot and collected several howto/tutorial on qmail and adopted them to my system and make a
easy step-by-step how-to, that made my work done. I hope this will help some other people who use/will use qmail.
I will revise this how-to time to time; you may give your valuable advise to me... in future I will host it my own site ...
My own web-site will be: http://www.linux-bd.com/
Mentionable reference howto/tutorial sites are as follows:
01. http://www.qmailrocks.org/
02. http://sylvestre.ledru.info/howto/howto_qmail_vpopmail.php
03. http://www.backschues.net/backschues.net/know-how/qmail.htm
04. http://www.lifewithqmail.org/
05. http://rauros.net/projects/qmail/index.php
06. http://www.inter7.com/
07. http://toribio.apollinare.org/qmail-scanner/
I have tested this howto on "Ubuntu Server Edition 8.10" and "9.04"
This how also should work on "Debian 5 Lenny" and "Ubuntu Server Edition 8.04.x LTS"
This how-to require work-experience with Linux specially with Debian/Ubuntu Platform.
I used root shell to configure my server ...
If you have any query regarding this how; you may mail me ... no restriction to re-distribute/modify this how-to...
The people I really give thanks always; to the following persons and other persons of open-source world ...
01. Linus Torvalds (http://en.wikipedia.org/wiki/Linus_Torveldts) - for Linux
02. Richard Matthew Stallman (http://en.wikipedia.org/wiki/Richard_Stallman) - for FSF
03. Daniel J. Bernstein (http://en.wikipedia.org/wiki/Daniel_J._Bernstein) - for qmail/djbdns
04. Mark Shuttleworth (http://en.wikipedia.org/wiki/Mark_Shuttleworth) - for Ubuntu
... and other people/organizaion of Open Source World.
NOTE:
This how to is scripted with Komodo Edit 5.1 in Ubuntu Desktop Edition 9.04 and printed as html from Komodo Edit 5.1
Which command you have apply in root terminal; I added "tc:" (t-terminal, c-command) before those Code Lines ...
I noted "Ubuntu 8.10 Server" as "8.10" and "Ubuntu Server 9.04" as "9.04"
Change the ip/domain name/password and other changeable information as your own ...
My How To is pretty straight-forward; Use your Linux Knowledge to explore more ...
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
STEP: 01- Install Ubuntu Server Edition 8.10/9.04 On a particular server/pc/vmware which will be your mail server/mail router.
Installation Requirements (While you install Ubuntu Server) Select the following pkg ....
>> LAMP Server (give mysql root password and keep it mind or write it somewhere)
>> OpenSSH Server
After you install the Operating System, Do the following check and assumption (put your own domain and ip) ...
Mail Server Host Name : mx
Mail Server Domain Name : linux-bd.com
Mail Server FQDN : mx.linux-bd.com
IP Address : 123.49.42.180
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
STEP: 02- Put IP Address on LAN Interface and Connect the Server/PC to Internet (Use the following System Command)
tc: vi /etc/network/interfaces
-----------------------------------------
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet static
address 123.49.42.180
netmask 255.255.255.224
network 123.49.42.160
broadcast 123.49.42.191
gateway 123.49.42.161
----------------------------------------
SAVE+EXIT
tc: /etc/init.d/networking restart
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
STEP: 03- Set your server host name; ensure your FQDN exits on host files (you might do this while install Ubuntu Server)
tc: vi /etc/hosts
---------------------------------------------------
127.0.0.1 localhost
123.49.42.180 mx.linux-bd.com mx
---------------------------------------------------
SAVE+EXIT
tc: vi /etc/hostname
-------------------------
mx
-------------------------
SAVE+EXIT
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
04- Update your apt source-list/software/application
tc: apt-get update
# for 8.10 only ...
tc: apt-get -q -y install build-essential libssl-dev libssl-dev openssl csh expect libgdbm-dev libmysqlclient15-dev
# for 9.04 only ...
tc: apt-get -q -y install build-essential libssl-dev libssl-dev openssl csh expect libgdbm-dev libmysqlclient16-dev unzip
# for 8.10 and 9.04
tc: apt-get -q -y install libpcre3 libpcre3-dbg libpcre3-dev libpcrecpp0 rcconf vim-nox iftop xinetd perl-suid
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
STEP: 05- Prepare your favorite text editor (mine is vim) and set syntax check on
tc: vim /etc/vim/vimrc
--------------------------------------------------------------------------------------------
" Vim5 and later versions support syntax highlighting. Uncommenting the next
" line enables syntax highlighting by default.
syntax on
--------------------------------------------------------------------------------------------
SAVE+EXIT
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
STEP: 06- Download my Qmail Packages tarball and do as follows;
I collected packages from sites and made a tarball ...
# WITHOUT THIS PACKAGES; SCRIPT COMMAND WILL NOT WORK PROPERLY
tc: mkdir /downloads
tc: cd /opt/
tc: wget http://www.linux-bd.com/qmail/qmail-rkarim-pkg.tar.gz
tc: tar zxvf qmail-rkarim-pkg.tar.gz
tc: cp /opt/qmail-install/qmailrocks.tar.gz /downloads/
tc: cd /opt/qmail-install/
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
STEP: 07- Unpacking qmail-1.03.tar.gz, ucspi-tcp-0.88.tar.gz and daemontools-0.76.tar.gz
tc: mkdir -p /var/qmail
tc: mkdir -p /usr/src/qmail
tc: cd /opt/qmail-install
tc: cp qmail-1.03.tar.gz ucspi-tcp-0.88.tar.gz /usr/src/qmail
tc: mkdir -p /package
tc: cp daemontools-0.76.tar.gz /package
tc: chmod 1755 /package
tc: cd /usr/src/qmail
tc: tar zxvf qmail-1.03.tar.gz
tc: tar zxvf ucspi-tcp-0.88.tar.gz
tc: cd /package
tc: tar zxvf daemontools-0.76.tar.gz
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
STEP: 08- Script to add users and groups for qmail
tc: vim quser.sh
---------------------------------------------------------------------------------
#!/bin/bash
groupadd nofiles
useradd -g nofiles -d /var/qmail/alias -s /sbin/nologin -p'*' alias
useradd -g nofiles -d /var/qmail -s /sbin/nologin -p'*' qmaild
useradd -g nofiles -d /var/qmail -s /sbin/nologin -p'*' qmaill
useradd -g nofiles -d /var/qmail -s /sbin/nologin -p'*' qmailp
groupadd qmail
useradd -g qmail -d /var/qmail -s /sbin/nologin -p'*' qmailq
useradd -g qmail -d /var/qmail -s /sbin/nologin -p'*' qmailr
useradd -g qmail -d /var/qmail -s /sbin/nologin -p'*' qmails
groupadd vchkpw
mkdir /home/vpopmail
useradd -g vchkpw -d /home/vpopmail -s /sbin/nologin -p'*' vpopmail
---------------------------------------------------------------------------------
SAVE+EXIT
tc: chmod 755 quser.sh
tc: ./quser.sh
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
STEP: 09- Creating logging directories
tc: mkdir /var/log/qmail
tc: cd /var/log/qmail
tc: mkdir qmail-send qmail-smtpd qmail-pop3d
tc: chown -R qmaill:root /var/log/qmail
tc: chmod -R 750 /var/log/qmail
tc: mkdir /var/qmail/supervise
tc: cd /var/qmail/supervise
tc: mkdir -p qmail-smtpd/log qmail-send/log qmail-pop3d/log
tc: chmod +t qmail-smtpd qmail-send qmail-pop3d
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
STEP: 10- Build and Install qmail-1.03
tc: cd /usr/src/qmail/qmail-1.03
tc: patch < /opt/qmail-install/qmail-patches/qmail-1.03-aio-patch-lastest
tc: echo 211 > /usr/src/qmail/qmail-1.03/conf-split
tc: echo 255 > /usr/src/qmail/qmail-1.03/conf-spawn
tc: make WITH_QMAILQUEUE_PATCH=yes setup check
tc: echo 255 > /var/qmail/control/concurrencyremote
tc: chmod 644 /var/qmail/control/concurrencyremote
tc: echo 1 > /var/qmail/control/mfcheck
tc: ./config-fast mx.linux-bd.com
tc: make cert
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
STEP: 11- Now Install ucspi-tcp
tc: cd /opt/qmail-install
tc: cd /usr/src/qmail/ucspi-tcp-0.88
tc: patch < /opt/qmail-install/qmail-patches/ucspi-tcp-0.88.errno.patch
tc: make
tc: make setup check
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
STEP: 12- Now Install daemontools
tc: cd /package/admin/daemontools-0.76
tc: cd src
tc: patch < /opt/qmail-install/qmail-patches/daemontools-0.76.errno.patch
tc: cd ..
tc: package/install
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
STEP: 13- Fixing the SVC Service of daemontools to work-with Ubuntu Server Editon 8x+
tc: vim /etc/event.d/svscan
# add/write the following lines ...
----------------------------------------------------------------
# svscan - daemontools
start on runlevel 2
start on runlevel 3
start on runlevel 4
start on runlevel 5
stop on runlevel 0
stop on runlevel 1
stop on runlevel 6
respawn
exec /command/svscanboot
----------------------------------------------------------------
SAVE + EXIT
tc: initctl start svscan
#Now run ps -aux as follows to see that svscan service is up and running
tc: ps -aux |grep svscan
# you should see the following output
--------------------------------------------------------------------------------------------------------------
Warning: bad ps syntax, perhaps a bogus '-'? See http://procps.sf.net/faq.html
root 4140 0.0 0.0 1844 504 ? Ss 08:21 0:00 /bin/sh /command/svscanboot
root 4184 0.0 0.0 1796 376 ? S 08:21 0:00 svscan /service
root 12446 0.0 0.0 3240 800 pts/0 S+ 13:53 0:00 grep svscan
---------------------------------------------------------------------------------------------------------------
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
STEP: 14- Get ready and Start your Qmail Service/Server (I used some qmailrocks script to minimize complexity)
tc: cd /downloads ; tar zxvf qmailrocks.tar.gz
tc: /downloads/qmailrocks/scripts/finalize/linux/finalize_linux.script
tc: vim /var/qmail/supervise/qmail-pop3d/run [ PUT "mx.linux-bd.com" in place of "mail.example.com" ; use your own FQDN]
tc: vim /var/qmail/supervise/qmail-smtpd/run [ PUT "mx.linux-bd.com" in place of "mail.example.com" ; use your own FQDN]
tc: qmailctl stop
# here you can also enter your network/lan subnet those you want to allow to use your server as smtp-server
tc: echo '127.:allow,RELAYCLIENT=""' >> /etc/tcp.smtp
tc: echo '123.49.42.180:allow,RELAYCLIENT=""' >> /etc/tcp.smtp
tc: echo '192.168.:allow,RELAYCLIENT=""' >> /etc/tcp.smtp
tc: qmailctl cdb
# change the domain name as your own ...
tc: echo postmaster@linux-bd.com > /var/qmail/alias/.qmail-root
tc: echo postmaster@linux-bd.com > /var/qmail/alias/.qmail-postmaster
tc: echo postmaster@linux-bd.com > /var/qmail/alias/.qmail-mailer-daemon
tc: ln -s /var/qmail/alias/.qmail-root /var/qmail/alias/.qmail-anonymous
tc: ln -s /var/qmail/alias/.qmail-postmaster /var/qmail/alias/.qmail-abuse
tc: chmod 644 /var/qmail/alias/.qmail*
tc: qmailctl start
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
STEP: 15- Make Symbolic Link for Sendmail
tc: rm -fr /usr/lib/sendmail # if file already exits
tc: rm -fr /usr/sbin/sendmail # if file already exits
tc: ln -s /var/qmail/bin/sendmail /usr/lib/sendmail
tc: ln -s /var/qmail/bin/sendmail /usr/sbin/sendmail
# It is now better to reboot your server but it is optional; you can avoid reboot....
reboot
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
STEP: 16- Install vpopmail with mysql integration
# Create vpopmail database, user and password ....
tc: mysql -u root -p # login with your mysql root password
# Output will be as follows .....
-----------------------------------------------------------------------------------------------------------------------------------------
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 270
Server version: 5.0.67-0ubuntu6 (Ubuntu)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
-----------------------------------------------------------------------------------------------------------------------------------------
# apply the following command on mysql console ...put your own password in place of "the_strong_password"
mysql>
mysql > create database vpopmail;
mysql > grant update, create, delete, insert, select on vpopmail.* to vpopmailuser@localhost identified by "the_strong_password";
mysql > flush privileges;
mysql> exit;
tc: mkdir -p /home/vpopmail/etc
tc: chown vpopmail:vchkpw /home/vpopmail/etc
tc: echo "localhost|0|vpopmailuser|the_strong_password|vpopmail" > /home/vpopmail/etc/vpopmail.mysql
tc: chown vpopmail:vchkpw /home/vpopmail/etc/vpopmail.mysql
tc: chmod 640 /home/vpopmail/etc/vpopmail.mysql
# Check that your vpopmail pasword is working properly ....
tc: mysql -u vpopmailuser -p # try to login with "the_strong_password" and must be successfull...
# Output will be as follows .....
-------------------------------------------------------------------------------------------------
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 270
Server version: 5.0.67-0ubuntu6 (Ubuntu)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> exit
Bye
-------------------------------------------------------------------------------------------------
# So, you are ready to install vpopmail itself now .....
tc: cd /opt/qmail-install
tc: tar zxvf vpopmail-5.4.26d.tar.gz
tc: cd vpopmail-5.4.26
tc: vim vconfig.sh
----------------------------------------------------------------------------------------------------------------------
./configure --enable-roaming-users=y --enable-logging=y --enable-ip-alias-domains=y \
--enable-auth-module=mysql --enable-clear-passwd=n --enable-libdir=/usr/lib/mysql/ \
--enable-tcpserver-path=/etc/ --enable-tcpserver-file=/etc/tcp.smtp --enable-qmail-ext \
--enable-logging=e --enable-tcprules-prog=/usr/local/bin/tcprules --enable-rebuild-tcpserver-file
----------------------------------------------------------------------------------------------------------------------
SAVE+ EXIT
tc: chmod 755 vconfig.sh
tc: ./vconfig.sh
tc: make && make install-strip
# Set the crontab to refresh your mysql connction session of users ....
tc: vim /etc/crontab
----------------------------------------------------------------------------------
40 * * * * root /home/vpopmail/bin/clearopensmtp 2>&1 > /dev/null
----------------------------------------------------------------------------------
SAVE+EXIT
# apply command ...
tc: /home/vpopmail/bin/clearopensmtp
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
STEP: 17- Ezlm, Autoresponder, Maildrop
# Ezlm
tc: cd /downloads/qmailrocks/ ; tar zxvf ezmlm-0.53-idx-0.41.tar.gz ; cd ezmlm-0.53-idx-0.41 ; make && make setup
# Autoresponder
tc: cd /downloads/qmailrocks/ ; tar zxvf autorespond-2.0.5.tar.gz ; cd autorespond-2.0.5 ; make && make install
# Maildrop
tc: cd /opt/qmail-install ; tar jxvf maildrop-2.0.4.20080726.tar.bz2 ; cd maildrop-2.0.4.20080726
tc: ./configure --prefix=/usr/local --exec-prefix=/usr/local --enable-maildrop-uid=root --enable-maildrop-gid=vchkpw --enable-maildirquota
tc: make && make install-strip && make install-man
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
STEP: 18- Install Vqadmin for GUI/Web-based for Mastering your total qmail server ...
tc: mkdir -p /var/www/html/images
tc: cd /opt/qmail-install
tc: tar zxvf vqadmin-2.3.7.tar.gz
tc: cd vqadmin-2.3.7
tc: ./configure --enable-cgibindir=/usr/lib/cgi-bin --enable-htmldir=/var/www/html
tc: make && make install-strip
tc: cd /usr/lib/cgi-bin/vqadmin/
tc: vim .htaccess
-----------------------------------------------------------
AuthType Basic
AuthUserFile /etc/apache2/vqadmin.passwd
AuthName vQadmin
require valid-user
satisfy any
-----------------------------------------------------------
SAVE+EXIT
tc: chown www-data .htaccess
tc: chmod 644 .htaccess
tc: vim /etc/apache2/apache2.conf
-------------------------------------------------------------------------------------------------------
# Put the follwing after ServerRoot Line as follows ...
ServerRoot "/etc/apache2" # find this line
ServerName mx # add this line after the live above
# and .... add the following lines at the end of the apache2.conf file (last end) ....
<Directory "/usr/lib/cgi-bin/vqadmin">
deny from all
Options ExecCGI
AllowOverride AuthConfig
Order deny,allow
</Directory>
-------------------------------------------------------------------------------------------------------
Save+Exit
# Create the password for web GUI login of VQADMIN PANNEL ....
tc: htpasswd -c /etc/apache2/vqadmin.passwd admin
----------------------------------------------------------------
# Output should be as follows ...
New password: "the_strong_password"
Re-type new password: "the_strong_password"
Adding password for user admin
----------------------------------------------------------------
tc: chown www-data /etc/apache2/vqadmin.passwd
tc: chmod 644 /etc/apache2/vqadmin.passwd
tc: /etc/init.d/apache2 restart
tc: mkdir /var/www/images
tc: cp -r /var/www/html/images/* /var/www/images/
NOW .... # you can use IP address <123.49.42.180> instead of mx.linux-bd.com to access web GUI
... ... open url http://mx.linux-bd.com/cgi-bin/vqadmin/vqadmin.cgi or
... ... open url http://123.49.42.180/cgi-bin/vqadmin/vqadmin.cgi
... ... and add domain "linux-bd.com" and set the "postmaster" password that will require to loging via QmailAdmin
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
STEP: 19- Install Qmail Admin the nice Qmail Domain Users/Email IDs Administration GUI Pannel
tc: cd /opt/qmail-install
tc: tar zxvf qmailadmin-1.2.12.tar.gz
tc: cd qmailadmin-1.2.12
tc: vim qmconfig.sh
---------------------------------------------------------------------------------------------------------------------------------------------
./configure --enable-htmldir=/var/www/html --enable-imagedir=/var/www/images --enable-imageurl=/images \
--enable-cgibindir=/usr/lib/cgi-bin/ --enable-autoresponder-bin=/usr/local/bin --enable-vpopuser=vpopmail \
--enable-ezmlmdir=/usr/local/bin/ezmlm/ --enable-ezmlmidx=y --enable-modify-quota --disable-ipauth --enable-help
---------------------------------------------------------------------------------------------------------------------------------------------
tc: chmod 755 qmconfig.sh
tc: ./qmconfig.sh
tc: make && make install-strip
tc: cd /etc/apache2/sites-available/
tc: vim mxadmin.linux-bd.com
----------------------------------------------------------------
<VirtualHost *:80>
ServerAdmin postmaster@linux-bd.com
ServerName mxadmin.linux-bd.com
DocumentRoot /var/www/
<Directory /var/www/>
AllowOverride AuthConfig Limit
Options SymLinksIfOwnerMatch Includes
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
ScriptAlias /global-cgi/ /usr/lib/cgi-bin/
</VirtualHost>
----------------------------------------------------------------
SAVE+EXIT
tc: ln -s /etc/apache2/sites-available/mxadmin.linux-bd.com /etc/apache2/sites-enabled/
tc: /etc/init.d/apache2 restart
# NOW ...# you can use IP address <123.49.42.180> instead of mxadmin.linux-bd.com to access web GUI
... open url "http://mxadmin.linux-bd.com/cgi-bin/qmailadmin" or
... open url "http://123.49.42.180/cgi-bin/qmailadmin"
login with "postmaster" password and domain name "linux-bd.com"
and add several email ids as you want ...
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
STEP: 20- Courier IMAP 4.x (One of critical qmial-imap service)
tc: apt-get install libltdl7 libltdl7-dev libguile-ltdl-1
tc: cd /opt/qmail-install
tc: tar jxvf courier-authlib-0.60.2.tar.bz2
tc: cd courier-authlib-0.60.2
tc: ./configure --prefix=/usr/local --exec-prefix=/usr/local --with-authvchkpw --without-authldap --without-authmysql --disable-root-check --with-ssl --with-authchangepwdir=/usr/local/libexec/authlib
tc: make && make check
tc: make install-strip && make install-configure
tc: vim /etc/rc.local
----------------------------------------------------------------
/usr/local/sbin/authdaemond start
----------------------------------------------------------------
SAVE+EXIT
# Now apply command ...
tc: /usr/local/sbin/authdaemond start
tc: useradd true # a add system user cause courier-imap should install as non-root user ...
tc: cd /opt/qmail-install
tc: tar jxvf courier-imap-4.3.0.tar.bz2
tc: chown -R true courier-imap-4.3.0
tc: cd courier-imap-4.3.0
tc: su true
tc: ./configure --prefix=/usr/local --exec-prefix=/usr/local --with-authvchkpw --without-authldap --without-authmysql --disable-root-check --with-ssl --with-authchangepwdir=/usr/local/libexec/authlib
tc: make && make check
tc: exit
tc: make install-strip && make install-configure
tc: /usr/local/sbin/mkimapdcert
tc: vim /usr/local/etc/imapd.cnf
----------------------------------------------------------------------------------------------------------------------------------
... change "postmaser@example.com" with "postmaster@linux-bd.com" as an administrative email address
----------------------------------------------------------------------------------------------------------------------------------
SAVE+EXIT
tc: vim /usr/local/etc/imapd # SET the following
----------------------------------------------------------------
IMAPDSTART=YES
----------------------------------------------------------------
SAVE+EXIT
tc: vim /usr/local/etc/imapd-ssl # SET the following
----------------------------------------------------------------
IMAPDSSLSTART=YES
TLS_CERTFILE=/usr/local/share/imapd.pem
----------------------------------------------------------------
SAVE+EXIT
tc: vim /usr/local/etc/authlib/authdaemonrc
-----------------------------------------
authmodulelist="authvchkpw"
-----------------------------------------
tc: cp /usr/local/libexec/imapd.rc /etc/init.d/imap
tc: cp /usr/local/libexec/imapd-ssl.rc /etc/init.d/imaps
tc: /usr/local/sbin/authdaemond stop ; /usr/local/sbin/authdaemond start
tc: /etc/init.d/imap stop ; /etc/init.d/imaps stop
tc: /etc/init.d/imap start ; /etc/init.d/imaps start
tc: vim /etc/rc.local # add the following two line ...
-----------------------------------------------------------------
/etc/init.d/imap start
/etc/init.d/imaps start
# also disable the following line ...in /etc/rc.local
csh -cf '/command/svscanboot &'
-----------------------------------------------------------------
SAVE+EXIT
tc: chmod 755 /etc/rc.local
# Veryfy your IMAP-SERVICE that it is running properly ...
tc: telnet localhost 143 # login must be successfull for imap
--------------------------------------------------------------------------------------------------------------------------
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
* OK [CAPABILITY IMAP4rev1 ...i cut here... distribution information
a login postmaster@linux-bd.com the_strong_password
a OK LOGIN Ok. (successful login!)
a logout
* BYE Courier-IMAP server shutting down
a OK LOGOUT completed
Connection closed by foreign host...
-------------------------------------------------------------------------------------------------------------------------
If all above everything goes fine ... you are ready to install webmail-client now...
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
STEP: 21- ROUNDCUBE-WEBMAIL CLIENT (AJAX BASED WEBMAIL CLIENT)
# Reference-1: http://wiki.qnap.com/wiki/RoundCube_Configuration
# Reference-2: http://www.howtoforge.com/roundcube_webmail_ispconfig
tc: apt-get -q -y install roundcube # and follow the onscreen steps just to meet the dependency and don't configure MYSQL-DB
#... you can download the latest roundcubemail from internet "http://roundcube.net/"
tc: cd /opt/qmail-install
tc: cp roundcubemail-0.2.1.tar.gz /var/www
tc: cd /var/www
tc: tar zxvf roundcubemail-0.2.1.tar.gz
tc: mv roundcubemail-0.2.1 mxwebmail
tc: cd mxwebmail
tc: chown -R www-data:www-data temp
tc: chown -R www-data:www-data logs
tc: rm -fr installer
tc: cd SQL
tc: mysql -u root -p # login to mysql as root
----------------------------------------------------------------------------------------
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 274
Server version: 5.0.67-0ubuntu6 (Ubuntu)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
-----------------------------------------------------------------------------------------
mysql>
mysql> CREATE DATABASE roundcubemail;
mysql> CREATE
USER 'rc_user'@'localhost' IDENTIFIED BY 'pw227829';
mysql> GRANT ALL PRIVILEGES ON roundcubemail.* TO rc_user@localhost IDENTIFIED BY 'pw227829'; # (put your own user/password)
mysql> use roundcubemail; source /var/www/mxwebmail/SQL/mysql.initial.sql;
mysql> FLUSH PRIVILEGES;
mysql> exit;
# Skip following if you dne steps (Tag-111)
# mysql -u root -p roundcubemail < mysql.initial.sql
tc: cd /var/www/mxwebmail/config/
tc: cp db.inc.php.dist db.inc.php
tc: cp main.inc.php.dist main.inc.php
tc: vim db.inc.php
----------------------------------------------------------------------------------------------------
# configure the following line as your need ...
$rcmail_config['db_dsnw'] = 'mysql://rc_user:pw227829@localhost/roundcubemail';
----------------------------------------------------------------------------------------------------
SAVE+EXIT
tc: vim main.inc.php
----------------------------------------------------------------------------------------------------
# configure the following lines as your need ...
$rcmail_config['default_host'] = 'localhost';
$rcmail_config['username_domain'] = 'linux-bd.com';
$rcmail_config['mail_domain'] = 'linux-bd.com';
$rcmail_config['smtp_server'] = 'localhost';
$rcmail_config['product_name'] = 'LINUXBD WEBMAIL';
$rcmail_config['create_default_folders'] = TRUE;
-----------------------------------------------------------------------------------------------------
SAVE+EXIT
# Configure Virtual hosting...
tc: cd /etc/apache2/sites-available/
tc: vim mx.linux-bd.com
----------------------------------------------------------------
<VirtualHost *:80>
ServerAdmin postmaster@linux-bd.com
ServerName mx.linux-bd.com
DocumentRoot /var/www/mxwebmail
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
# Again set the location you want to serve sites from
<Directory /var/www/mxwebmail>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
----------------------------------------------------------------
SAVE+EXIT
tc: ln -s /etc/apache2/sites-available/mx.linux-bd.com /etc/apache2/sites-enabled/
tc: /etc/init.d/apache2 restart
# NOW ...# you can use IP address <123.49.42.180> instead of mxadmin.linux-bd.com to access web GUI
..... open url "http://mx.linux-bd.com/" or
..... open url "http://123.49.42.180/mxwebmail"
..... login with "email-id" and "password"
..... Enjoy roundcuebe webmail.
### Now this is one fo most critical part of mail server is filtering ....
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
STEP: 22- Install SpamAssassin
# run ....
tc: apt-get -q -y install spamassassin spamc
# now run rcconf and de-select "SpamAssassin"
tc: rcconf
tc: vim /etc/rc.local # and add the following line
----------------------------
/usr/sbin/spamd -d
----------------------------
SAVE+EXIT
tc: groupadd spamd
tc: useradd -g spamd -s /bin/false spamd
tc: cd /etc/mail/spamassassin/
tc: cp local.cf local.cf.ori
tc: echo " " > local.cf
tc: vim local.cf
# add the following lines (you can copy/past)...
----------------------------------------------------------------
required_hits 5.0
add_header all Report _REPORT_
rewrite_header Subject 1
add_header spam Flag _YESNOCAPS_
add_header all Status _YESNO_, score=_SCORE_ required=_REQD_ tests=_TESTS_ autolearn=_AUTOLEARN_ version=_VERSION_
add_header all Level _STARS(*)_
add_header all Checker-Version SpamAssassin _VERSION_ (_SUBVERSION_) on _HOSTNAME_
dns_available yes
skip_rbl_checks 0
----------------------------------------------------------------
SAVE+EXIT
tc: vim /etc/default/spamassassin
# ensure following lines exists and change if require
----------------------------------------------------------------
ENABLED=1
OPTIONS="--create-prefs --max-children 5 --helper-home-dir"
PIDFILE="/var/run/spamd.pid"
CRON=0
----------------------------------------------------------------
SAVE+EXIT
# run ...
tc: /usr/sbin/spamd -d
# see the process is running by
tc: pgrep spamd
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
STEP: 23- Install Clamav Anti Virus
tc: groupadd clamav
tc: useradd -g clamav -s /bin/false -c "Clam AntiVirus" clamav
tc: groupadd qscand
tc: useradd -g qscand -s /bin/false -c "Qmail-Scanner Account" qscand
tc: cd /opt/qmail-install/
tc: tar zxvf clamav-0.95.1.tar.gz
tc: cd clamav-0.95.1/
tc: ./configure
tc: make
tc: make install
tc: cd /usr/local/etc/
tc: cp clamd.conf clamd.conf.ori
tc: cp freshclam.conf freshclam.conf.ori
tc: echo "" > clamd.conf
tc: vim clamd.conf
----------------------------------------------------------------
LogFile /var/log/clamav/clamd.log
LogTime yes
LogSyslog yes
PidFile /var/run/clamav/clamd.pid
DatabaseDirectory /var/lib/clamav
LocalSocket /var/lib/clamav/clamd.socket
User qscand
AllowSupplementaryGroups yes
ScanMail yes
PhishingSignatures yes
PhishingScanURLs yes
----------------------------------------------------------------
SAVE+EXIT
tc: echo "" >freshclam.conf
tc: vim freshclam.conf
----------------------------------------------------------------
DatabaseDirectory /var/lib/clamav
UpdateLogFile /var/log/clamav/freshclam.log
LogFileMaxSize 2M
LogTime yes
LogSyslog yes
PidFile /var/run/clamav/freshclam.pid
DatabaseOwner qscand
DNSDatabaseInfo current.cvd.clamav.net
DatabaseMirror database.clamav.net
MaxAttempts 5
ScriptedUpdates yes
NotifyClamd /usr/local/etc/clamd.conf
----------------------------------------------------------------
SAVE+EXIT
tc: mkdir -p /var/log/clamav
tc: touch /var/log/clamav/clamd.log
tc: touch /var/log/clamav/freshclam.log
tc: chmod 777 /var/log/clamav/clamd.log
tc: chmod 777 /var/log/clamav/freshclam.log
tc: mkdir -p /var/run/clamav
tc: chown -R qscand:qscand /var/log/clamav
tc: chown -R qscand:qscand /var/run/clamav
tc: usermod -g qscand clamav
tc: mkdir -p /var/lib/clamav
tc: chown -R qscand:qscand /var/lib/clamav
tc: vim /etc/crontab
-------------------------------------------------------------------------------------------------
20 4 * * * root /usr/local/bin/freshclam -d -c 2 -l /var/log/clamav/freshclam.log
-------------------------------------------------------------------------------------------------
Save+Exit
tc: apt-get install libclamav5 # 8.10
tc: apt-get install libclamav6 # 9.04
tc: /usr/local/bin/freshclam -l /var/log/clamav/freshclam.log # wait until update done
# run ...
tc: /usr/local/sbin/clamd # add this line in /etc/rc.local
tc: /usr/local/bin/freshclam -l /var/log/clamav/freshclam.log # to check update
tc: vim /etc/rc.local # add the following line...
----------------------------
/usr/local/sbin/clamd
----------------------------
SAVE+EXIT
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
STEP: 24- Install Qmail-Scanner and Integrate with clamd+spamd
tc: cd /opt/qmail-install
tc: tar zxvf q-s-2.06st-20090419.tgz
tc: cd qmail-scanner-2.06st
tc: cp /opt/qmail-install/qms-config /opt/qmail-install/qmail-scanner-2.06st/
tc: vim qms-config
# ... Please change domain name "linux-bd.com" as your own
----------------------------------------------------------------
# qms-config file ...
./configure --domain "linux-bd.com" \
--admin postmaster \
--local-domains "linux-bd.com" \
--add-dscr-hdrs yes \
--dscr-hdrs-text "X-Antivirus-LINUXBD.COM" \
--ignore-eol-check yes \
--sa-quarantine 0.1 \
--sa-delete 5.0 \
--sa-reject no \
--sa-subject ":SPAM:" \
--sa-alt yes \
--sa-debug no \
--notify admin \
--redundant yes \
--silent-viruses auto \
--unzip 1 \
--archive 0 \
--log-details yes \
--fix-mime 1 \
--settings-per-domain yes \
"$INSTALL"
----------------------------------------------------------------
tc: chmo 755 qms-config
tc: ./qms-config # answer Y to all question
tc: ./qms-config install # answer Y to all question
tc: setuidgid qscand /var/qmail/bin/qmail-scanner-queue.pl -z
tc: setuidgid qscand /var/qmail/bin/qmail-scanner-queue.pl -g
tc: setuidgid qscand /var/qmail/bin/qmail-scanner-queue.pl -p
tc: chown -R qscand:qscand /var/spool/qscan
# Testing the qmail-scanner; thait it is working properly or not ...
tc: chmod 755 /opt/qmail-install/qmail-scanner-2.06st/contrib/test_installation.sh
# run ...
tc: /opt/qmail-install/qmail-scanner-2.06st/contrib/test_installation.sh -doit
# Sample successfull output bellow ...
----------------------------------------------------------------------------------------------
Sending standard test message - no viruses... 1/4
done!
Sending eicar test virus - should be caught by perlscanner module... 2/4
done!
Sending eicar test virus with altered filename - should only be caught by commercial anti-virus modules (if you have any)... 3/4
done!
Sending bad spam message for anti-spam testing - In case you are using SpamAssassin... 4/4
If you have enabled $sa_quarantine, $sa_delete or $sa_reject the
spam-message wont arrive to the recipients. But if you have enabled
(good idea!) 'minidebug' or 'debug' you should check
/var/spool/qscan/qmail-queue.log (or where ever you have the log).
Done!
Finished test. Now go and check Email sent to "postmaster@linux-bd.com" and/or the log..
------------------------------------------------------------------------------------------------
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
STEP: 25- Activate QMAIL-SCANNER and RBL-SMTP check
# Activate Qmail-Scanner to scan your incomming and outgoing mail with RBL-SMTP check as follows
tc: vim /var/qmail/supervise/qmail-smtpd/run
# add the folowing line at the begining ...
QMAILQUEUE="/var/qmail/bin/qmail-scanner-queue.pl"; export QMAILQUEUE
# replace lines starting from "exec /usr/local/bin/softlimit -m 180000000" and put the following till to end of file ...
exec /usr/local/bin/softlimit -m 180000000 \
/usr/local/bin/tcpserver -v -R -l "$LOCAL" -x /etc/tcp.smtp.cdb -c "$MAXSMTPD" \
-u "$QMAILDUID" -g "$NOFILESGID" 0 smtp \
/usr/local/bin/rblsmtpd -b -r bl.spamcop.net -r zen.spamhaus.org -r dnsbl.sorbs.net -r dnsbl.njabl.org \
/var/qmail/bin/qmail-smtpd mx.linux-bd.com \
/var/qmail/bin/qmail-smtpd 2>&1
# OR you can copy/past my following /var/qmail/supervise/qmail-smtpd/run (edit your domain name part)
-------------------------------------------------------------------------------------------------------------------------------------
#!/bin/sh
QMAILQUEUE="/var/qmail/bin/qmail-scanner-queue.pl"; export QMAILQUEUE
QMAILDUID=`id -u vpopmail`
NOFILESGID=`id -g vpopmail`
MAXSMTPD=`cat /var/qmail/control/concurrencyincoming`
LOCAL=`head -1 /var/qmail/control/me`
if [ -z "$QMAILDUID" -o -z "$NOFILESGID" -o -z "$MAXSMTPD" -o -z "$LOCAL" ]; then
echo QMAILDUID, NOFILESGID, MAXSMTPD, or LOCAL is unset in
echo /var/qmail/supervise/qmail-smtpd/run
exit 1
fi
if [ ! -f /var/qmail/control/rcpthosts ]; then
echo "No /var/qmail/control/rcpthosts!"
echo "Refusing to start SMTP listener because it'll create an open relay"
exit 1
fi
exec /usr/local/bin/softlimit -m 180000000 \
/usr/local/bin/tcpserver -v -R -l "$LOCAL" -x /etc/tcp.smtp.cdb -c "$MAXSMTPD" \
-u "$QMAILDUID" -g "$NOFILESGID" 0 smtp \
/usr/local/bin/rblsmtpd -b -r bl.spamcop.net -r zen.spamhaus.org -r dnsbl.sorbs.net -r dnsbl.njabl.org \
/var/qmail/bin/qmail-smtpd mx.linux-bd.com \
/var/qmail/bin/qmail-smtpd 2>&1
------------------------------------------------------------------------------------------------------------------------------------
SAVE+EXIT
# reloading qmail service
tc: qmailctl stop
tc: qmailctl cdb
tc: qmailctl start
# Finally Check your /etc/rc.local files ...
tc: vim /etc/rc.local
----------------------------------------------------------------
# you should have the following lines ...
/usr/local/sbin/authdaemond start
/etc/init.d/imap start
/etc/init.d/imaps start
/usr/sbin/spamd -d
/usr/local/sbin/clamd
# csh -cf '/command/svscanboot &' <this line must be disabled>
exit 0 # this line "exit 0" should be at the end of rc.local file
----------------------------------------------------------------
# NOW REBOOT YOUR SERVER and CHECK EVERYTHING THAT THEY ARE WORKING OR NOT...
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
STEP: 26- Watching the log files ...
tc: tail -f /var/log/qmail/qmail-send/current # qmail send/receive log
tc: tail -f /var/log/qmail/qmail-smtpd/current # qmail smtp log
tc: tail -f /var/log/qmail/qmail-pop3d/current # qmail pop3 log
tc: tail -f /var/spool/qscan/qmail-queue.log # qmail-scanner log
tc: qmailctl queue
tc: qmailctl stat
tc: qmailctl flush
OK; we all done to configure a mail-server with qmail...
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
STEP: 27- Some extra Qmail stuff...
# This one is easy. You already have the user "qscand"
# since you needed it for qmail-scanner to work. Now, you're just going to
# make it easy to check the quarantine from any mail reader.
tc: mkdir /home/qscand/
tc: ln -s /var/spool/qscan/quarantine /home/qscand/Maildir
tc: chown -R qscand:qscand /home/qscand
tc: passwd qscand
# Configuring qmail to remotely clean e-mail as SMTP ROUTER
tc: echo "linux-bd.com" >> /var/qmail/control/locals
tc: vim /var/qmail/control/rcpthosts
----------------------------------------------------------------
linux-bd.com
otherdom.com
etherdom.com
ctherdom.com
----------------------------------------------------------------
tc: vim /var/qmail/control/smtproutes
----------------------------------------------------------------
otherdom.com:123.49.42.173
etherdom.com:123.49.42.171
ctherdom.com:123.49.42.165
----------------------------------------------------------------
tc: echo "linux-bd.com" >> /var/qmail/control/doublebouncehost
tc: echo "doublebounce" >> /var/qmail/control/doublebounceto
tc: echo "#" >> /var/qmail/alias/.qmail-doublebounce
# also you can add the follwoing firewall lines to you iptables firewall
tc: vim /usr/bin/mail-fire.sh
# *********************************************************************************************************************************************
echo -e "\nLOADING MAIL SERVER FIREWALL ... ..."
echo 1 > /proc/sys/net/ipv4/ip_forward
# do not accept source routed packets
echo "0" > /proc/sys/net/ipv4/conf/all/accept_source_route
# do not accept ICMP redirects
echo "1" > /proc/sys/net/ipv4/conf/all/accept_redirects
echo -e "INITIALIZING FIREWALL ... ..."
iptables -F INPUT
iptables -F OUTPUT
iptables -F FORWARD
iptables -F -t mangle
iptables -F -t nat
iptables -F
iptables -X
iptables -Z
iptables -t nat -F
iptables -t nat -X
iptables -t nat -Z
iptables --table nat -F
iptables --delete-chain
iptables --table nat --delete-chain
iptables -t mangle --delete-chain
echo -e "LOADING FIREWALL MODULES ... ..."
/sbin/modprobe ip_tables
/sbin/modprobe ip_queue
/sbin/modprobe iptable_filter
/sbin/modprobe iptable_mangle
/sbin/modprobe iptable_nat
/sbin/modprobe ipt_limit
/sbin/modprobe ipt_LOG
/sbin/modprobe ipt_MASQUERADE
/sbin/modprobe ipt_multiport
/sbin/modprobe ipt_REDIRECT
/sbin/modprobe ipt_REJECT
/sbin/modprobe ipt_state
/sbin/modprobe ip_conntrack_pptp
/sbin/modprobe ip_nat_pptp
/sbin/modprobe ip_nat_ftp
/sbin/modprobe ip_conntrack
/sbin/modprobe ip_conntrack_ftp
echo -e "DEFINING VARIABLES ... ..."
WAN_IF="eth0"
IPT="/sbin/iptables"
IPTABLES="/sbin/iptables"
SERVER_IP="123.49.42.180" # Mail Server IP address
# -----------------------------------------------------
echo -e "DROPPING ALL BY DEFAULT ... ..."
$IPTABLES -F INPUT
$IPTABLES -P INPUT DROP
$IPTABLES -F OUTPUT
$IPTABLES -P OUTPUT ACCEPT
$IPTABLES -F FORWARD
$IPTABLES -P FORWARD ACCEPT
echo -e " this is drop spamcop lasso ...."
FILE="/tmp/drop.lasso"
URL="http://www.spamhaus.org/drop/drop.lasso"
echo ""
echo -n "Applying DROP list to existing firewall..."
[ -f $FILE ] && /bin/rm -f $FILE || :
cd /tmp
wget $URL
blocks=$(cat $FILE | egrep -v '^;' | awk '{ print $1}')
iptables -N droplist
for ipblock in $blocks
do
iptables -A droplist -s $ipblock -j LOG --log-prefix "DROP List Block"
iptables -A droplist -s $ipblock -j DROP
done
iptables -I INPUT -j droplist
iptables -I OUTPUT -j droplist
iptables -I FORWARD -j droplist
echo "...Done"
/bin/rm -f $FILE
echo -e " this is drop lasso end ...."
echo -e "SETTING FIREWALL RULES... ..."
$IPTABLES -A INPUT -i lo -j ACCEPT
$IPTABLES -A INPUT -i $WAN_IF -j ACCEPT
$IPTABLES -A INPUT -i $WAN_IF -m state --state ESTABLISHED,RELATED -j ACCEPT
# Enable incoming traffic ....
for i in 22 25 53 80 443 110 143 78 21 20 993 783
do
$IPTABLES -A INPUT -i $WAN_IF -p tcp --dport $i -j ACCEPT
done
# Allow DNS(udp)
$IPTABLES -A INPUT -i $WAN_IF -p udp --dport 53 -j ACCEPT
#SNMP monitoring so I can use a remote monitoring tool
iptables -A INPUT -p udp -m udp --dport 161 -j ACCEPT
iptables -A INPUT -p udp -m udp --sport 1023:2999 -j ACCEPT
#end SNMP
echo -e "ALLOWING ICMP ... ..."
iptables -A INPUT -p icmp --icmp-type 8 -s 0/0 -d $SERVER_IP -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -p icmp --icmp-type 0 -s 0/0 -d $SERVER_IP -m state --state ESTABLISHED,RELATED -j ACCEPT
echo -e "DROPPING SYN/ICMP FLOOD ... ..."
iptables -N syn_flood
iptables -A INPUT -p tcp --syn -j syn_flood
iptables -A syn_flood -m limit --limit 1/s --limit-burst 3 -j RETURN
iptables -A syn_flood -j DROP
#Limiting the incoming icmp ping request:
iptables -A INPUT -p icmp -m limit --limit 1/s --limit-burst 1 -j ACCEPT
#iptables -A INPUT -p icmp -m limit --limit 1/s --limit-burst 1 -j LOG --log-prefix PING-DROP:
iptables -A INPUT -p icmp -j DROP
#$IPTABLES -A FORWARD -j LOG
echo -e "MAIL FIREWALL [DONE]"
# *********************************************************************************************************************************************
SAVE+EXIT
tc: chmod 755 /usr/bin/mail-fire.sh
# add this fire-wall script to crontab
tc: vim /etc/crontab
----------------------------------------------------------------
50 6 * * * root /usr/bin/mail-fire.sh
----------------------------------------------------------------
SAVE+EXIT
# Backup qmail log files ...
tc: vim /usr/bin/qlog_bak.sh
------------------------------------------------------------------------------------
#!/bin/bash
cp -r /var/log/qmail/qmail-send /home/qmail-log/`date +%d_%m_%Y`
------------------------------------------------------------------------------------
SAVE+EXIT
tc: mkdir /home/qmail-log ; chmod 755 /usr/bin/qlog_bak.sh
# add this to crontab ....
tc: vim /etc/crontab
----------------------------------------------------------------
50 23 * * * root /usr/bin/qlog_bak.sh
----------------------------------------------------------------
SAVE+EXIT
# run ...
tc: /usr/bin/qlog_bak.sh
tc: ls -l /home/qmail-log/
---------------------------------------------------------------------
total 4
drwxr-x--- 3 root root 4096 2009-04-30 23:50 30_04_2009
---------------------------------------------------------------------
*********************************************************************************************************************
### If anyone want to use dovecot .... you may use the following howto ... (I did not tested it ...)
### I found it http://probing.wikidot.com/installing-qmail-on-debian
cd /var/src
wget http://www.dovecot.org/releases/1.1/dovecot-1.1.4.tar.gz
groupadd dovecot
useradd -g dovecot -d /virtual/dovecot -s /bin/false dovecot
usermod -a -G mail dovecot
groupadd dovecotauth
useradd -g dovecotauth -d /virtual/dovecot -s /bin/false dovecotauth
tar xzpf dovecot-1.1.4.tar.gz && cd dovecot-1.1.4
./configure --prefix=/virtual/dovecot --without-pgsql --without-pop3d --without-pam \
--without-passwd --without-shadow --without-bsdauth --without-deliver --without-passwd-file \
--without-nss --without-checkpassword --without-static-userdb --with-mysql --with-vpopmail
make
make install
cd /virtual/dovecot/etc
mv dovecot-example.conf dovecot.conf
mv dovecot-sql-example.conf dovecot-sql.conf
rm -rf dovecot-db-example.conf
rm -rf dovecot-ldap-example.conf
id vpopmail //(right it down somewhere)//
--------------------------
vim dovecot.conf
--------------------------
protocols = imaps
disable_plaintext_auth = yes
log_path = /var/log/dovecot.log
login_greeting = IMAP ready. Have an account?
user = dovecot
login_user = dovecotauth
mail_uid = 64020 //(from id vpopmail)//
mail_gid = 64020 //(from id vpopmail)//
passdb sql {
args = /virtual/dovecot/etc/dovecot-sql.conf
}
userdb sql {
args = /virtual/dovecot/etc/dovecot-sql.con
}
user = dovecot
count = 1
ssl_disable = no
--------------------------
vim dovecot-sql.conf
--------------------------
driver = mysql
connect = host=/var/run/mysqld/mysqld.sock user=vpopmailuser password=the_strong_password dbname=vpopmail
default_pass_scheme = PLAIN
password_query = SELECT CONCAT(pw_name, '@', pw_domain) AS user, pw_clear_passwd AS password FROM vpopmail WHERE pw_name = '%n' AND pw_domain = '%d'
user_query = SELECT pw_dir as home, 64020 AS uid, 64020 AS gid FROM vpopmail WHERE pw_name = '%n' AND pw_domain = '%d'
--------------------------
touch /var/log/dovecot.log
vim /etc/init.d/dovecot
--------------------------
#! /bin/sh
### BEGIN INIT INFO
# Provides: dovecot
# Required-Start: $syslog
# Required-Stop: $syslog
# Should-Start: $local_fs
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Dovecot init script
# Description: Init script for dovecot services
### END INIT INFO
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/virtual/dovecot/sbin/dovecot
NAME=dovecot
DESC="mail server"
test -x $DAEMON || exit 0
set -e
# The init script should do nothing if dovecot is being run from inetd
for p in `sed -r "s/^ *(([^:]+|\[[^]]+]|\*):)?(pop3s?|imaps?)[ \t].*/\3/;t;d" \
/etc/inetd.conf`
do
for q in `sed -r "s/^ *protocols[ \t]*=[ \t]*(([^\"]*)|\"(.*)\")/\2\3/;t;d" \
/virtual/dovecot/etc/dovecot.conf`
do
if [ $p = $q ]; then
exit 0
fi
done
done
case "$1" in
start)
if grep protocols /virtual/dovecot/etc/dovecot.conf | sed 's/#.*$//' | tr -d '"' | \
egrep -q '[^#]*(\bpop3s?\b|\bimaps?\b)';
then
if [ -x /virtual/dovecot/libexec/dovecot/imap-login -a -x /virtual/dovecot/libexec/dovecot/imap ] \
|| [ -x /virtual/dovecot/libexec/dovecot/pop3-login -a -x /virtual/dovecot/libexec/dovecot/pop3 ];
then
echo -n "Starting $DESC: $NAME"
start-stop-daemon --start --quiet --oknodo --exec $DAEMON
echo "."
fi
fi
;;
stop)
echo -n "Stopping $DESC: $NAME "
start-stop-daemon --stop --quiet --oknodo --exec $DAEMON
echo "."
;;
#reload)
#
# If the daemon can reload its config files on the fly
# for example by sending it SIGHUP, do it here.
#
# If the daemon responds to changes in its config file
# directly anyway, make this a do-nothing entry.
#
# echo -n "Reloading $DESC configuration..."
# start-stop-daemon --stop --signal 1 --quiet --pidfile \
# /var/run/$NAME.pid --exec $DAEMON
# echo "done."
#;;
restart|force-reload)
#
# If the "reload" option is implemented, move the "force-reload"
# option to the "reload" entry above. If not, "force-reload" is
# just the same as "restart".
#
echo -n "Restarting $DESC: $NAME"
start-stop-daemon --stop --quiet --oknodo --exec $DAEMON
sleep 1
start-stop-daemon --start --quiet --oknodo --exec $DAEMON
echo "."
;;
*)
N=/etc/init.d/$NAME
# echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
echo "Usage: $N {start|stop|restart|force-reload}" >&2
exit 1
;;
esac
exit 0
--------------------------
chmod +x dovecot
update-rc.d dovecot defaults
update-rc.d -f vpopmail-mysql remove //(instead of using pop3 from qmail)//
./dovecot start
Starting mail server: dovecotWarning: Corrected permissions for login directory /virtual/dovecot/var/run/dovecot/login //(normal)//
cd /var/src/dovecot-1.1.4/doc
nano dovecot-openssl.cnf
chmod +x mkcert.sh
sh mkcert.sh