У нас также установиться сам Courier-IMAP, Если кому то не нужен доступ к почте по POP3
протоколу то можно не ставить courier-pop3 а сразу ставить courier-imap
После установки правим файл /etc/rc.local для запуска courier сервисов:
Добавим следующие строки:
#Courier-Imap settings
if [ -x /usr/local/libexec/imapd.rc -a -x /usr/local/libexec/imapd-ssl.rc ]; then
mkdir -p /var/run/courier-imap
echo -n ' imapd'; /usr/local/libexec/imapd.rc start
echo -n ' pop3d'; /usr/local/libexec/pop3d.rc start (опять же если не используем POP3 можно эту строчку убрать)
fi
Откроем файл для редактирования /etc/rc.shutdown для того чтобы сервисы отключались корректно
при рестарте системы:
#Courier-Imap settings
if [ -x /usr/local/libexec/imapd.rc -a -x /usr/local/libexec/imapd-ssl.rc ]; then
echo -n ' imapd'; /usr/local/libexec/imapd.rc stop
echo -n ' pop3d'; /usr/local/libexec/pop3d.rc stop
fi
Поставим courier-mysql чтобы Courier-IMAP мог работать с MySQL:
Создадим директорию где у нас будут храниться пиьсма. Так как у нас Postfix будет запускаться
в chroot то место должно быть где то в /var/spool/postfix.
Далее правим основной файл конфигурации Postfix. Для этого откроем файл для редактирования
/etc/postfix/main.cf:
И внесем такие изменения в файл найдите и исправьте каждую строчку если такой нету то
допишите:
user = postfix
password = postfix
hosts = localhost
dbname = postfix
query = SELECT maildir FROM mailbox WHERE username='%s'
И некоторые штучки от спама:
# mkdir /etc/postfix/maps
# touch /etc/postfix/maps/body_checks
# This will reject emails where any line contains eight or more script/comment tags.
#/(<!(--|[^>]*>).*){8}/ REJECT Your email contained a lot of script tags. Please
correct this (try setting your mail program to use plain text) and resend your message.
# This will reject emails with script/comment tags that are in the middle of a word.
#/^.*[a-z]<![a-z]*[0-9]*>[a-z]/ REJECT Your email contained wrongly placed script tags.
Please correct this (try setting your mail program to use plain text) and resend your message.
# This will reject some variants of Sobig viruses
/^RSLxwtYBDB6FCv8ybBcS0zp9VU5of3K4BXuwyehTM0RI9IrSjVuwP94xfn0wgOjouKWzGXHVk3qg$/ REJECT Your email looked like it
contained a virus. Please run a virus scanner on your computer and try again.
/^TVqQAAMAAAAEAAAA//8AALgAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA$/ REJECT Your email looked like
it contained a virus. Please run a virus scanner on your computer and try again.
## Bad worlds
/porno/ REJECT Body Spam Rule 1
/viagra/ REJECT Body Spam Rule 2
/penis/ REJECT Body Spam Rule 3
/kamasutra/ REJECT Body Spam Rule 4
/bitch/ REJECT Body Spam Rule 5
/V~I~A~G~R~A/ REJECT Body Spam Rule 6
/p"enis/ REJECT Body Spam Rule 7
/e"nlarde/ REJECT Body Spam Rule 8
# touch /etc/postfix/maps/header_checks
/^Subject .*Free Money/ REJECT Spam Header Rule #1
#X-Mailer Blocks
IF/^X-Mailer:/
/ Virtual MailSender; www.vpro.ru/ OK
/ 0001/ REJECT Your email had spam-like header contents. (X-Mailer)
/ Avalanche/ REJECT Your email had spam-like header contents. (X-Mailer)
/ Crescent Internet Tool/ REJECT Your email had spam-like header contents. (X-Mailer)
/ DiffondiCool/ REJECT Your email had spam-like header contents. (X-Mailer)
/ E-Mail Delivery Agent/ REJECT Your email had spam-like header contents. (X-Mailer)
/ Emailer Platinum/ REJECT Your email had spam-like header contents. (X-Mailer)
/ Entity/ REJECT Your email had spam-like header contents. (X-Mailer)
/ Extractor/ REJECT Your email had spam-like header contents. (X-Mailer)
/ Floodgate/ REJECT Your email had spam-like header contents. (X-Mailer)
/ GOTO Software Sarbacane/ REJECT Your email had spam-like header contents. (X-Mailer)
/ MailWorkz/ REJECT Your email had spam-like header contents. (X-Mailer)
/ MassE-Mail/ REJECT Your email had spam-like header contents. (X-Mailer)
/ MaxBulk.Mailer/ REJECT Your email had spam-like header contents. (X-Mailer)
/ News Breaker Pro/ REJECT Your email had spam-like header contents. (X-Mailer)
/ SmartMailer/ REJECT Your email had spam-like header contents. (X-Mailer)
/ StormPort/ REJECT Your email had spam-like header contents. (X-Mailer)
/ SuperMail-2/ REJECT Your email had spam-like header contents. (X-Mailer)
/ RAdvanced Direct Remailer/ REJECT Your email had spam-like header contents. (X-Mailer)
/ Advanced Mass Sender/ REJECT Your email had spam-like header contents. (X-Mailer)
/ Spammer/ REJECT Your email had spam-like header contents. (X-Mailer)
/ Bomber/ REJECT Your email had spam-like header contents. (X-Mailer)
/ Mega-Mailer/ REJECT Your email had spam-like header contents. (X-Mailer)
/ SuperMail/ REJECT Your email had spam-like header contents. (X-Mailer)
/ FastMailer/ REJECT Your email had spam-like header contents. (X-Mailer)
/ PObox/ REJECT Your email had spam-like header contents. (X-Mailer)
/ MMailer/ REJECT Your email had spam-like header contents. (X-Mailer)
/ Ligra Mailer/ REJECT Your email had spam-like header contents. (X-Mailer)
/ Dynamic Opt-In Emailer/ REJECT Your email had spam-like header contents. (X-Mailer)
/ Group Spamer/ REJECT Your email had spam-like header contents. (X-Mailer)
/ Mail Sender/ REJECT Your email had spam-like header contents. (X-Mailer)
/ Mailloop/ REJECT Your email had spam-like header contents. (X-Mailer)
/ PersMail/ REJECT Your email had spam-like header contents. (X-Mailer)
/ LK SendI/ REJECT Your email had spam-like header contents. (X-Mailer)
/ WC Mail/ REJECT Your email had spam-like header contents. (X-Mailer)
/ Virtual MailSender/ REJECT Your email had spam-like header contents. (X-Mailer)
/ ZUBA ZUB/ REJECT Your email had spam-like header contents. (X-Mailer)
/ MailList Express/ REJECT Your email had spam-like header contents. (X-Mailer)
/ Caretop/ REJECT Your email had spam-like header contents. (X-Mailer)
/ Mailer Signature/ REJECT Your email had spam-like header contents. (X-Mailer)
/ FiG/ REJECT Your email had spam-like header contents. (X-Mailer)
/ PG-MAILINGLIST/ REJECT Your email had spam-like header contents. (X-Mailer)
/ advcomtest/ REJECT Your email had spam-like header contents. (X-Mailer)
/ ailerv/ REJECT Your email had spam-like header contents. (X-Mailer)
/ Gailerj/ REJECT Your email had spam-like header contents. (X-Mailer)
/ User$/ REJECT Your email had spam-like header contents. (X-Mailer)
/ ....... / REJECT Your email had spam-like header contents. (X-Mailer)
/ sklsgwd/ REJECT Your email had spam-like header contents. (X-Mailer)
/ yo yo mail/ REJECT Your email had spam-like header contents. (X-Mailer)
/ ZanziMailer/ REJECT Your email had spam-like header contents. (X-Mailer)
/ smsmtp/ REJECT Your email had spam-like header contents. (X-Mailer)
/ BulkMailer/ REJECT Your email had spam-like header contents. (X-Mailer)
/ diffondi/ REJECT Your email had spam-like header contents. (X-Mailer)
/ Virtual MailSender/ REJECT Your email had spam-like header contents. (X-Mailer)
/ Version 5.0 / REJECT Your email had spam-like header contents. (X-Mailer)
/ NetMasters/ REJECT Your email had spam-like header contents. (X-Mailer)
/ nethack/ REJECT Your email had spam-like header contents. (X-Mailer)
/ Dipost/ REJECT Your email had spam-like header contents. (X-Mailer)
/ (ACE ContactManager|CyberCreek Avalanche)/ REJECT Your email had spam-like header contents. (X-Mailer)
/ (Achi-Kochi Mail|E-mail Magnet|Mailcast)/ REJECT Your email had spam-like header contents. (X-Mailer)
/ (Group Mail|Aristotle Mail|WorldMerge)/ REJECT Your email had spam-like header contents. (X-Mailer)
/ (Extractor Pro|Floodgate Pro|MultiMailer)/ REJECT Your email had spam-like header contents. (X-Mailer)
/ (Ellipse Bulk Emailer|RamoMail|MultiMailer)/ REJECT Your email had spam-like header contents. (X-Mailer)
/ (Emailer Platinum.*Internet Marketing)/ REJECT Your email had spam-like header contents. (X-Mailer)
/ E-Magazine/ REJECT Your email had spam-like header contents. (X-Mailer)
/ ExclamationSoft/ REJECT Your email had spam-like header contents. (X-Mailer)
/ IM2K/ REJECT Your email had spam-like header contents. (X-Mailer)
/ PostMaster General/ REJECT Your email had spam-like header contents. (X-Mailer)
/ Advanced Mass Sender/ REJECT Your email had spam-like header contents. (X-Mailer)
/ EZ Version/ REJECT Your email had spam-like header contents. (X-Mailer)
/ Email Collector/ REJECT Your email had spam-like header contents. (X-Mailer)
/ SBZ systems/ REJECT Your email had spam-like header contents. (X-Mailer)
/ The Red Spider/ REJECT Your email had spam-like header contents. (X-Mailer)
/ Dynamic Opt-In Emailer/ REJECT Your email had spam-like header contents. (X-Mailer)
/ IM2000 Version 1.01/ REJECT Your email had spam-like header contents. (X-Mailer)
/ Prospect Mailer/ REJECT Your email had spam-like header contents. (X-Mailer)
/ Inet_Mail_Out/ REJECT Your email had spam-like header contents. (X-Mailer)
/ MailKing/ REJECT Your email had spam-like header contents. (X-Mailer)
/ David/ REJECT Your email had spam-like header contents. (X-Mailer)
/ EzyMassMailer/ REJECT Your email had spam-like header contents. (X-Mailer)
/ Oshirase-Mailer/ REJECT Your email had spam-like header contents. (X-Mailer)
/ The Red Spider/ REJECT Your email had spam-like header contents. (X-Mailer)
/ Mega-Mailer/ REJECT Your email had spam-like header contents. (X-Mailer)
/ FletMail/i REJECT Your email had spam-like header contents. (X-Mailer)
/ Floodgate/ REJECT Your email had spam-like header contents. (X-Mailer)
/ Extractor/ REJECT Your email had spam-like header contents. (X-Mailer)
/ Fusion/ REJECT Your email had spam-like header contents. (X-Mailer)
/ MassE-Mail/ REJECT Your email had spam-like header contents. (X-Mailer)
/ Quick Shot/ REJECT Your email had spam-like header contents. (X-Mailer)
/ NetMailer/ REJECT Your email had spam-like header contents. (X-Mailer)
/ WorldMerge/ REJECT Your email had spam-like header contents. (X-Mailer)
/ Powermailer/ REJECT Your email had spam-like header contents. (X-Mailer)
/ homosexual/ REJECT Your email had spam-like header contents. (X-Mailer)
/ PSS Bulk Mailer.*$/ REJECT Your email had spam-like header contents. (X-Mailer)
/ ccMail Link.*$/ REJECT Your email had spam-like header contents. (X-Mailer)
/ IXO-Mail.*$/ REJECT Your email had spam-like header contents. (X-Mailer)
/ MMailer.*$/ REJECT Your email had spam-like header contents. (X-Mailer)
/ K-ML.*$/ REJECT Your email had spam-like header contents. (X-Mailer)
/ GoldMine.*$/ REJECT Your email had spam-like header contents. (X-Mailer)
/ MAGIC.*$/ REJECT Your email had spam-like header contents. (X-Mailer)
/ bomber.*$/ REJECT Your email had spam-like header contents. (X-Mailer)
/ expeditor.*$/ REJECT Your email had spam-like header contents. (X-Mailer)
/ Brooklyn North.*$/ REJECT Your email had spam-like header contents. (X-Mailer)
/ Broadcast.*$/ REJECT Your email had spam-like header contents. (X-Mailer)
/ DMailer.*$/ REJECT Your email had spam-like header contents. (X-Mailer)
/ Extractor.*$/ REJECT Your email had spam-like header contents. (X-Mailer)
/ EMailing List Pro .*$/ REJECT Your email had spam-like header contents. (X-Mailer)
/ Fusion.*$/ REJECT Your email had spam-like header contents. (X-Mailer)
/ News Breaker .*$/ REJECT Your email had spam-like header contents. (X-Mailer)
/ dbMail.*$/ REJECT Your email had spam-like header contents. (X-Mailer)
/ Unity.*$/ REJECT Your email had spam-like header contents. (X-Mailer)
/ PG-MAILINGLIST PRO .*$/ REJECT Your email had spam-like header contents. (X-Mailer)
/ Dynamic.*$/ REJECT Your email had spam-like header contents. (X-Mailer)
/ Splio.*$/ REJECT Your email had spam-like header contents. (X-Mailer)
/ Sarbacane.*$/ REJECT Your email had spam-like header contents. (X-Mailer)
/ sMailing.*$/ REJECT Your email had spam-like header contents. (X-Mailer)
/ Broadc@st.*$/ REJECT Your email had spam-like header contents. (X-Mailer)
/ WorkZ.*$/ REJECT Your email had spam-like header contents. (X-Mailer)
/ ABMailer.*$/ REJECT Your email had spam-like header contents. (X-Mailer)
/ QuickSender .*$/ REJECT Your email had spam-like header contents. (X-Mailer)
/.* over 2182 or.$/ REJECT Your email had spam-like header contents. (X-Mailer)
/ SpeedMail_.*$/ REJECT Your email had spam-like header contents. (X-Mailer)
ENDIF
#Other Headers Blocks
/^X-Unsent: 1/ REJECT Possible you have a virus Nimbda. Try resend your message.
# These are headers used to track some spam messages.
/^Bel-Tracking: .*/ REJECT Confirmed spam. Go away.
/^Hel-Tracking: .*/ REJECT Confirmed spam. Go away.
/^Kel-Tracking: .*/ REJECT Confirmed spam. Go away.
/^BIC-Tracking: .*/ REJECT Confirmed spam. Go away.
/^Lid-Tracking: .*/ REJECT Confirmed spam. Go away.
# touch /etc/postfix/maps/mime_header_checks
# This entry will reject messages with attachments that could be dangerous, and will inform the sender of what type of attachemnt was rejected.
/^s*Content-
(Disposition|Type).*names*=s*"?(.+.(ad[ep]|asd|ba[st]|c[ho]m|cmd|cpl|crt|dbx|dll|exe|hlp|hta|in[fs]|isp|js|jse|lnk
|md[etw]|ms[cipt]|nws|ocx|ops|pcd|pi|pif|prf|reg|scf|scr|sct|sh[bms]|swf|uue|vb|vb[esx]|vxd|wab|ws[cfh]))"?s*$/
REJECT Files attached to emails that contain or end in "$3" are prohibited on this server as they may contain viruses. The file named "$2" was rejected.
# chown -R www.www postfixadmin/
# cd /var/www/users/yourwebdir/postfixadmin
# chmod 640 *.php *.css
# cd /var/www/users/yourwebdir/postfixadmin/admin/
# chmod 640 *.php .ht*
# cd /var/www/users/yourwebdir/postfixadmin/images/
# chmod 640 *.png
# cd /var/www/users/yourwebdir/postfixadmin/languages/
# chmod 640 *.lang
# cd /var/www/users/yourwebdir/postfixadmin/templates/
# chmod 640 *.tpl
# cd /var/www/users/yourwebdir/postfixadmin/users/
# chmod 640 *.php
Создадим базу данных в MySQL с помощью файла - скрипта в дирректории postfixadmin:
# mysql -u root -p < DATABASE_MYSQL.TXT
Система попросит ввести пароль который мы задавали выше для root mysql. Вводим и получаем базу
данных.
Создадим файл конфигурации из станлдартного для postfixadmin
# cd /var/www/htdocs/postfixadmin/
# cp config.inc.php.sample config.inc.php
Зайдем на созданый сайт добавим домены, майлы, администраторов доменов.
P.S. Настройка PF фаирвола для всего этого:
Небольшая и простая настройка фаирвола:
Внешний интерфейс
ext_if="xl0"
Внутренний интерфейс
int_if="xl1"
Блокируем на внешнем интерфейсе все:
block on $ext_if all
Пропускаем изнутри то что хочет попасть наружу:
pass out on $ext_if all keep state
Откроем порт 80 для Apache:
pass in on $ext_if proto tcp to any port {80}
Откроем порт 53 для DNS:
pass in on $ext_if proto {udp, tcp} to any port {53}
Откроем порты для почты:
pass in on $ext_if proto {tcp, udp} to any port {25}
pass in on $ext_if proto {tcp, udp} from any to any port {143,110}
P.P.S. В итоге мы получем работающий почтовый сервер с поддержкой нескольких доменов, и
управлением всего этого через прекрасный скрипт Postfixadmin.
Перезагружаемся!
Исследуем лог файлы в дирректории /var/log/
maillog - лог собственно postfix`a и courier`a
messages - лог при старте системы пишет все что запускается или не запускается..
/var/www/logs/ - логи от веб сервера Apache
Шаг 5: Прикручиваем Анти-Спам систему.
Так как amavisd-new и Spamassasin написаны на perl?, то они используют
перловские модули.
Подробно описывать каждый параметр конфига я не буду. Кому интересно поищите
информацию на официальном сайте SpamAsssasin http://spamassassin.apache.org
Создадим и настроим домашную дирректорию для spamassassin и amavisd:
Отредактируем файл и изменим следующие строки /etc/mail/spamassassin/v310.pre
Снимите значок коментария # с двух строк как показано ниже:
# DCC - perform DCC message checks.
#
# DCC is disabled here because it is not open source. See the DCC
# license for more details.
#
loadplugin Mail::SpamAssassin::Plugin::DCC
# Razor2 - perform Razor2 message checks.
#
# Razor2 is disabled here because it is not available for unlimited free
# use. It is currently free for personal use, subject to capacity
# constraints. See the Cloudmark SpamNet Service Policy for more details.
#
loadplugin Mail::SpamAssassin::Plugin::Razor2
Включить и выключить Razor мы сможем отредактировав файл /etc/mail/spamassassin/local.cf
изменив значение use_razor2 1 на use_razor2 0
Razor пишет свой собственный лог файл /var/amavisd/.razor/razor-agent.log
Файл будет рости в обьеме, что чревато последствиями если про него забыли. Так что после того
как вы убедились что все работает правильно и красиво отредактируйте файл
/var/amavisd/.razor/razor-agent.conf сменив debuglevel = 3 на debuglevel = 0 и перезапустите
amavisd.
На фаирволе порт 2703 изнутри-наружу должен быть открыт
Установка и настрока DCC:
Переходим в нашу дирректорию:
# cd /root
Скачаем и установим последую версию DCC (http://www.dcc-servers.net/dcc/)
# ftp http://www.dcc-servers.net/dcc/source/dcc-dccd.tar.Z
# tar -zxvf dcc-dccd.tar.Z
# cd cd dcc-dccd-1.3.44
# ./configure
Запустим:
# /usr/local/bin/cdcc 'info'
Если увидите что то типо этого (на фаирволее порт 6277 изнутри-наружу должен быть открыт):
dcc.rhyolite.com, - RTT+0 ms anon
# 153.19.44.233,- coral.ely.pg.gda.pl WEiAPG? server-ID 1072
# 100% of 3 requests ok 1687.64+0 ms RTT 113 ms queue wait
# 192.188.61.3,- calcite.rhyolite.com Rhyolite server-ID 101
# 100% of 2 requests ok 755.52+0 ms RTT 50 ms queue wait
Далее нам надо настроить чтобы это все запускалось в chroot.
Перейдем в директорию /var/amavisd, все далее выполненые команды должны выполняться именно
находясь в этой директории:
# cd/var/amavisd
# mkdir -p etc dev tmp var/run bin
# mkdir -p usr/bin usr/share/zoneinfo usr/lib usr/libexec
Правим файл /etc/fstab
Найдем раздел /var и уберем с него параметр nodev:
Было так:
/dev/wd0g /var ffs rw,nodev,nosuid 1 2
Стало так:
/dev/wd0g /var ffs rw,nosuid 1 2
Если этого не зделать amavisd быть отвечать о проблемах, ошибках.
Перезагружаемся!
Продолжаем:
# cd /var/amavisd
# mknod dev/null с 2 2
Зделаем несколько линков:
# ln -s / var/amavisd
Скопируем файлы конфигураций в нашу chroot директорию. Если вы в дальнейшем будете менять эти
фалы их надо будет заново скопировать в наш chroot.
Здеалем маленький скриптик для копирования нужных файлов в наш chroot с названием ldd_copy.sh
и с таким содержанием:
#!/bin/sh
PATH=/bin:/sbin:/usr/bin:/usr/sbin
if [ "$1" != "" -a "$2" != "" ]; then
for i in `ldd $1 | egrep "(rlib|rtld)" | cut -f17 -d" "`
do
if [ ! -e $2$i ]; then
cp $i $2$i
echo $i $2$i copied
else
echo $2$i already exists
fi
done
else
echo "Usage: ldd_copy.sh <program> <destination>"
fi
Все что осталось это отредактировать файл postfix - /etc/postfix/master.cf
Приведите его к такому виду:
#
# Postfix master process configuration file. For details on the format
# of the file, see the master(5) manual page (command: "man 5 master").
#
# ==========================================================================
# service type private unpriv chroot wakeup maxproc command + args
# (yes) (yes) (yes) (never) (100)
# ==========================================================================
smtp inet n - n - 10 smtpd
-o content_filter=smtp-amavis:[127.0.0.1]:10024
smtp-amavis unix - - n - 3 smtp
-o smtp_data_done_timeout=1200
-o disable_dns_lookups=yes
127.0.0.1:10025 inet n - n - - smtpd
-o local_recipient_maps=
-o smtpd_restriction_classes=
-o smtpd_client_restrictions=
-o smtpd_helo_restrictions=
-o smtpd_sender_restrictions=
-o smtpd_recipient_restrictions=permit_mynetworks,reject,reject_unauth_destination
-o strict_rfc821_envelopes=yes
#original
#smtp inet n - - - - smtpd
....
Перезагрузитесь и я надеюсь что у вас все заработает!
Статья не претендует не на что, создавался как мануал для себя чтобы не забыть чего то.
При написании за основу брались статьи и конференции:
- http://www.obsd.ru
- http://www.postfixwiki.org
- http://www.flakshack.com/anti-spam/wiki/
- http://www.securitystage.com
Я не утвреждаю что все это придумал я сам. Это все взято с тех или иных
источников отмеченных выше, просто переработано, переведено на более
менее понятный язык
Версия 2.0
С уважением syntax
О всех недочетах отзывах и тд. Пишите на майл syntax at forsale.lv