본문 바로가기
리눅스(Linux)

Qmail & Vpopmail & Spamassassin

by sinn 2010. 4. 24.

스팸필터링 메일 서버 설치 가이드<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

 

구성 

qmail1.03(cocktail14+chkuser-0.6.patch)+vpopmail5.4.0+courier-imap-4.1.2

squirrelmail-1.4.8 rpm 패키지

qmailadmin 1.0.6 +ClamAV 0.92+qmail-scanner-1.24+Spamassassin-3.24

 

프로그램 소스: /usr/local/src/qmail

 

1.      qmail 설치

참고 :

http://qmail.kldp.org/

http://vitro.pe.kr/

http://www.spamassassin.org/

 

 

Ucspi-tcp 설치

--------------------------------------------------------------

[root@ns1 root]# tar xvf ucspi-tcp-0.88.tar

[root@ns1 ucspi-tcp 0.88]# patch -p1 <../ucspi-tcp-0.88.errno.patch

[root@ns1 ucspi-tcp 0.88]# make && make setup check

 

--------------------------------------------------------------

Daemontools 설치

--------------------------------------------------------------

mkdir /package

cd /package

[root@ns1 root]# tar xvf daemontools-0.76.tar

[root@ns1 daemontools-0.76]# patch -p1 < ../daemontools-0.76.errno.patch

[root@ns1 daemontools-0.76]# package/install

[root@ns1 root]# rm -rf /service

--------------------------------------------------------------

Qmail 설치

--------------------------------------------------------------

# 센드메일 제거

mv /usr/sbin/sendmail /usr/sbin/sendmail.orig

mv /usr/lib/sendmail /usr/lib/sendmail.orig

 

mkdir /var/qmail

 

groupadd nofiles

useradd -g nofiles -d /var/qmail qmaild

useradd -g nofiles -d /var/qmail/alias alias

useradd -g nofiles -d /var/qmail qmaill

useradd -g nofiles -d /var/qmail qmailp

groupadd qmail

useradd -g qmail -d /var/qmail qmailq

useradd -g qmail -d /var/qmail qmailr

useradd -g qmail -d /var/qmail qmails

[root@ns1 root]# tar xvf qmail-1.03-linux.tar; cd qmail-1.03

[root@ns1 qmail-1.03]# patch -p1 < ../qmail-1.03.errno.patch

[root@ns1 qmail-1.03]# mkdir /var/qmail && make && make setup check

 

 

 

 

--------------------------------------------------------------

Qmail 설정

--------------------------------------------------------------

[root@ns1 qmail-1.03]# ./config-fast 메일서버도메인명

mkdir -p /var/qmail/supervise/qmail-send/log

mkdir -p /var/qmail/supervise/qmail-smtpd/log

chmod +t /var/qmail/supervise/qmail-send

chmod +t /var/qmail/supervise/qmail-smtpd

 

vi /var/qmail/supervise/qmail-send/run

#!/bin/sh

exec /var/qmail/rc

 

vi /var/qmail/supervise/qmail-send/log/run

#!/bin/sh

exec /usr/local/bin/setuidgid qmaill /usr/local/bin/multilog t /var/log/qmail

 

vi /var/qmail/supervise/qmail-smtpd/run

#!/bin/sh

Q_UID=`id -u qmaild`

Q_GID=`id -g qmaild`

exec /usr/local/bin/softlimit -m 8000000 \

/usr/local/bin/tcpserver -vRHl0 -x/etc/tcp.smtp.cdb \

-u $Q_UID -g $Q_GID 0 25 \

/var/qmail/bin/qmail-smtpd /bin/true 2>&1

 

vi /var/qmail/supervise/qmail-smtpd/log/run

#!/bin/sh

exec /usr/local/bin/setuidgid qmaill /usr/local/bin/multilog t /var/log/qmail/smtpd

 

chmod 755 /var/qmail/supervise/qmail-send/run

chmod 755 /var/qmail/supervise/qmail-send/log/run

chmod 755 /var/qmail/supervise/qmail-smtpd/run

chmod 755 /var/qmail/supervise/qmail-smtpd/log/run

mkdir -p /var/log/qmail/smtpd

chown qmaill /var/log/qmail /var/log/qmail/smtpd

cd ~alias

echo root > .qmail-mailer-daemon

echo root > .qmail-postmaster

echo root > .qmail-root

chmod 644 .qmail-mailer-daemon .qmail-postmaster .qmail-root

 

# 큐메일 구동 스크립트 파일

vi /etc/init.d/qmail

#-------------------------------------------------------------------------------------------

#!/bin/sh

# Source function library.

# . /etc/init.d/functions

 

# Source networking configuration.

# . /etc/sysconfig/network

 

# Check that networking is up.

# [ ${NETWORKING} = "no" ] && exit 0

 

PATH=/var/qmail/bin:/usr/local/bin:/usr/bin:/bin

export PATH

case "$1" in

start)

echo -n "Starting qmail: svscan"

cd /var/qmail/supervise

env - PATH="$PATH" svscan &

echo $! > /var/run/svscan.pid

echo "."

;;

stop)

echo -n "Stopping qmail: svscan"

kill `cat /var/run/svscan.pid`

echo -n " qmail"

svc -dx /var/qmail/supervise/*

echo -n " logging"

svc -dx /var/qmail/supervise/*/log

echo "."

;;

stat)

cd /var/qmail/supervise

svstat * */log

;;

doqueue|alrm)

echo "Sending ALRM signal to qmail-send."

svc -a /var/qmail/supervise/qmail-send

;;

queue)

qmail-qstat

qmail-qread

;;

reload|hup)

echo "Sending HUP signal to qmail-send."

svc -h /var/qmail/supervise/qmail-send

;;

pause)

echo "Pausing qmail-send"

svc -p /var/qmail/supervise/qmail-send

echo "Pausing qmail-smtpd"

svc -p /var/qmail/supervise/qmail-smtpd

;;

cont)

echo "Continuing qmail-send"

svc -c /var/qmail/supervise/qmail-send

echo "Continuing qmail-smtpd"

svc -c /var/qmail/supervise/qmail-smtpd

;;

restart)

echo "Restarting qmail:"

echo "* Stopping qmail-smtpd."

svc -d /var/qmail/supervise/qmail-smtpd

echo "* Sending qmail-send SIGTERM and restarting."

svc -t /var/qmail/supervise/qmail-send

echo "* Restarting qmail-smtpd."

svc -u /var/qmail/supervise/qmail-smtpd

;;

cdb)

tcprules /etc/tcp.smtp.cdb /etc/tcp.smtp.tmp < /etc/tcp.smtp

chmod 644 /etc/tcp.smtp*

echo "Reloaded /etc/tcp.smtp."

;;

help)

cat <<HELP

stop -- stops mail service (smtp connections refused, nothing goes out)

start -- starts mail service (smtp connection accepted, mail can go out)

pause -- temporarily stops mail service (connections accepted, nothing leaves)

cont -- continues paused mail service

stat -- displays status of mail service

cdb -- rebuild the tcpserver cdb file for smtp

restart -- stops and restarts smtp, sends qmail-send a TERM & restarts it

doqueue -- sends qmail-send ALRM, scheduling queued messages for delivery

reload -- sends qmail-send HUP, rereading locals and virtualdomains

queue -- shows status of queue

alrm -- same as doqueue

hup -- same as reload

HELP

;;

*)

echo "Usage: $0 {start|stop|restart|doqueue|reload|stat|pause|cont|cdb|queue|help}"

exit 1

;;

esac

 

exit 0

 

#-------------------------------------------------------------------------------------------

[root@ns1 root]# chmod 755 /etc/init.d/qmail

[root@ns1 root]#chkconfig add qmail

[root@ns1 root]#chkconfig qmail on

 [root@ns1 root]# vi /etc/tcp.smtp

127.0.0.1:allow,RELAYCLIENT=""

:allow

 

/etc/init.d/qmail cdb

ln -s /var/qmail/bin/sendmail /usr/lib/sendmail

ln -s /var/qmail/bin/sendmail /usr/sbin/sendmail

cp /var/qmail/boot/proc /var/qmail/rc

 

cat /var/qmail/rc

#!/bin/sh

exec env - PATH="/var/qmail/bin:$PATH" \

qmail-start ./Maildir/ splogger qmail

 

 [root@ns1 root]# /etc/init.d/qmail start

 

#--------------------------------------------------------------

Qmail 테스트

#--------------------------------------------------------------

[root@ns1 root]# su - test

[test@ns1 test]$/var/qmail/bin/maildirmake ~/Maildir

[test@ns1 test]$echo ./Maildir/ > ~/.qmail;exit

[test@ns1 test]$echo to: test | /var/qmail/bin/qmail-inject

[test@ns1 test]$find ~test/Maildir/new

-rw------- 1 nobody nobody 525 Dec 30 <?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" />12:03 1009681426.28068.webmail

 

2.    Vpopmail 설치

 

# vpopmail 그룹 및 계정 생성

groupadd vchkpw

useradd -g vchkpw vpopmail

 

tar zxvf vpopmail-5.4.0.tar.gz

cd vpopmail-5.4.0.tar

 

#./configure --enable-roaming-users=y --enable-tcprules-prog=/usr/local/bin/tcprules --enable-relay-clear-minutes=15 --enable-aut

h-logging=y --enable-logging=e --disable-clear-passwd

#make;make install-strip

 

# 릴레이 설정

echo "127.0.0.:allow,RELAYCLIENT=\"\"" > ~vpopmail/etc/tcp.smtp

echo ":allow" >> ~vpopmail/etc/tcp.smtp

tcprules /home/vpopmail/etc/tcp.smtp.cdb \

/home/vpopmail/etc/tcp.smtp.tmp < /home/vpopmail/etc/tcp.smtp

/home/vpopmail/bin/clearopensmtp

 

# crontab 설정

/etc/crontab 추가

40 * * * * /home/vpopmail/bin/clearopensmtp

 

 

# pop3 시동 파일 생성

mkdir /var/qmail/supervise/qmail-pop3d

 

cat /var/qmail/supervise/vpop/run

 

#!/bin/sh

exec /usr/local/bin/softlimit -m 20000000 \

/usr/local/bin/tcpserver -v -R -H -l 0 0 110 /var/qmail/bin/qmail-popup  \

도메인명 \ /home/vpopmail/bin/vchkpw /var/qmail/bin/qmail-pop3d Maildir 2>&1

 

# POP3 구동

#cd /service

#ln s /var/qmail/ supervise/qmail-pop3d qmail-pop3d

 

#netstat nlp

110번 포트 떠있는지 확인

 

 

 

3.    Courier-imap 설치

# courier-authlib 0.60.2 설치 ( imap 인증 처리에 필요)

./configure

make;make install;make install-configure

 

/usr/local/sbin/authdaemond start

 

# 시스템 시작 시 자동 시작될 수 있도록 /etc/rc.local에 추가

echo /usr/local/sbin/authdaemond start >> /etc/rc.local

 

# courier-imap 4.1.2 설치

su 일반계정 예) su test

 

$./configure --with-redhat

$make;make check

$ su root

# make install

# make install-configure

#cp courier-imap.sysvinit /etc/init.d/courier-imap

#chkconfig --add courier-imap

#chkconfig courier-imap on

 

#vi /etc/courier-imap/imapd

 

ADDRESS=127.0.0.1->ADDRESS=0 수정 (로컬에서만 사용하면 수정할 필요 없음)

IMAPDSTART=NO-> IMAPDSTART=YES로 수정

 

#/etc/init.d/courier-imap start -> imapd 구동

 

 

 

 

4.    squirrelmail, qmailadmin 설치

 

1)    squirrelmail 설치

#yum y install squirrelmail

#cd /usr/share/squirrelmail/config

 #./conf.pl (환경설정)

1 Enter (Organization Preferences)-> 자신에게 맞게 적절히 설정한다.

2 Enter (Server Settings)

 1. Domain -> 자신의 도메인 세팅

 3. Sendmail or SMTP : SMTP

A (Update IMAP Settings) 누르고 들어가 세팅

4.  IMAP Server            : 127.0.0.1

5.  IMAP Port              : 143

    B (Update SMTP Settings) 누르고 들어가 세팅

  4.   SMTP Server           : 192.168.100.100 (메일서버 ip)

5.   SMTP Port             : 25

 

3.       Folder Defaults 아래항목 변경

3.  Trash Folder                  : INBOX.Trash

4.  Sent Folder                   : INBOX.Sent

5.  Drafts Folder                 : INBOX.Drafts

 

10. Languages 아래와 같이 설정

1.  Default Language       : ko_KR

2.  Default Charset        : euc-KR

 S 누르고 저장

 나머지는 필요에 의해 알아서 설정하면 됩니다.

 

아파치 설정은 가상호스트에 잡아서 적절히 설정하시면 됩니다.

 

2)    qmailadmin 설치 (http://jikime.tistory.com/421 참조)

A.     autorespond 설치

ezmlm에서 필요로 하는 프로그램입니다

 

#wget http://www.inter7.com/devel/autorespond-2.0.2.tar.gz

#tar zxvf autorespond-2.0.2.tar.gz

#cd autorespond-2.0.2

#make

# cp pv autorespond /usr/local/bin

 

 B. ezmlm 설치

qmail과 같이 사용할 수 있는 쉽고 빠른 메일링 리스트 프로그램

#wget http://www.ezmlm.org/archive/5.1.2/ezmlm-idx-5.1.2.tar.gz

#tar zxvf ezmlm-idx-5.1.2.tar.gz

#cd ezmlm-idx-5.1.2

#make;make man;make setup

 

C.qmailadmin 설치

웹으로 vpopmail을 관리할 수 있는 프로그램

 

#wget http://downloads.sourceforge.net/qmailadmin/qmailadmin-1.2.12.tar.gz?modtime=1194986500&big_mirror=0

#tar zxvf qmailadmin-1.2.12.tar.gz

#cd qmailadmin-1.2.12

 

root@localhost qmailadmin-1.2.12# ./configure \

--enable-htmllibdir=/usr/local/qmailadmin \

--enable-htmldir=/usr/local/qmailadmin \

--enable-cgibindir=/usr/local/qmailadmin \

--enable-imagedir=/usr/local/qmailadmin/images \

--enable-imageurl=/images \

--enable-cgipath=/index.cgi

root@localhost qmailadmin-1.2.12#make;make install-strip

root@localhost qmailadmin-1.2.12#cd /usr/local/qmailadmin/

root@ qmailadmin#ln -sf qmailadmin index.cgi

 

아파치 VirtualHost 설정

[root@ns qmailadmin]# vi /usr/local/apache/conf/httpd.conf
<VirtualHost 192.168.100.1>
    ServerAdmin 관리자이메일주소

    DocumentRoot /usr/local/qmailadmin -> qmailadmin 설치 디렉터리
    ServerName 도메인명 -> 웹으로 접속할 도메인

    <Directory /usr/local/qmailadmin>
       
Options FollowSymLinks ExecCGI
       
AllowOverride AuthConfig
   
</Directory>
</VirtualHost>

 

http://도메인명 으로 접속해서 페이지 뜨면 정상적으로 설치된 것임

 

 

4.    ClamAV 설치

<PRE>ClamAV 전용 계정 생성</PRE><PRE>#groupadd clamav</PRE><PRE style="tab-stops: 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt">#useradd -g clamav -s /bin/false -c "Clam AntiVirus" clamav</PRE><PRE style="tab-stops: 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt"> </PRE><PRE>#tar zxvf clamav-x.yz.tar.gz </PRE><PRE style="tab-stops: 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt">#cd clamav-x.yz</PRE><PRE>#./configure --sysconfdir=/etc</PRE><PRE>#make</PRE><PRE>#make install</PRE><PRE>환경설정 파일 수정 </PRE><PRE style="tab-stops: 25.0pt 45.8pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt">vi /etc/clamd.conf</PRE><PRE style="tab-stops: 25.0pt 45.8pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt">Example-> #Example 수정</PRE><PRE style="tab-stops: 25.0pt 45.8pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt">다른 내용은 수정안해도 구동은 됩니다. 자신의 필요에 맞게 수정하세요.</PRE><PRE style="tab-stops: 25.0pt 45.8pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt"> </PRE><PRE style="tab-stops: 25.0pt 45.8pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt">Vi /etc/freshclam.conf</PRE><PRE style="tab-stops: 25.0pt 45.8pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt">Example-> #Example 수정</PRE><PRE style="tab-stops: 25.0pt 45.8pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt">바이러스 엔진 자동업데이트 설정</PRE><PRE># touch /var/log/freshclam.log</PRE><PRE># chmod 600 /var/log/freshclam.log</PRE><PRE># chown clamav /var/log/freshclam.log</PRE><PRE># freshclam -d</PRE><PRE style="tab-stops: 25.0pt 45.8pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt"> </PRE><PRE style="tab-stops: 25.0pt 45.8pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt">/etc/crontab에 설정</PRE><PRE>1 * * * *        /usr/local/bin/freshclam –quiet </PRE><PRE style="tab-stops: 25.0pt 45.8pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt"> </PRE><PRE style="tab-stops: 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt">#cd clamav-x.yz/contrib/init</PRE><PRE style="tab-stops: 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt">#cp RedHat /etc/init.d/clamd </PRE><PRE style="tab-stops: 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt">#chkconfig –add clamd</PRE><PRE style="tab-stops: 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt">#chkconfig clamd on</PRE>

 

 

5. maildrop install

maildrop qmail-scanner가 이메일을 검사하기 위한 이메일 포맷을스캔가능한 형태로 변환하기 위해 maildrop reformime이란 기능을 이용한다.그러니 반드시 maildrop을 설치하여야 한다

 

[root@localhost maildrop-1.5.0]# ./configure \

--prefix=/usr \

--sysconfdir=/etc \

--localstatedir=/var \

--mandir=/usr/share/man \

--enable-sendmail=/var/qmail/bin/sendmail \

--enable-maildrop-uid=root \

--enable-maildrop-gid=wheel \

--enable-maildirquota \

--enable-restrict-trusted=1 \

--enable-trusted-users='root qmaild vpopmail'

[root@localhost maildrop-1.5.0]# make && make install-strip && make install-man

 

 

 

6. SpamAssassin-3.24 설치 ::

의존성에 걸리는 패키지를 설치하기 귀찮은 분들은  CPAN를 이용하세요.

<PRE style="TEXT-INDENT: 24pt; mso-char-indent-count: 2.0">#perl -MCPAN -e shell (root 계정으로 실행)</PRE><PRE style="TEXT-INDENT: 24pt; mso-char-indent-count: 2.0">install Mail::SpamAssassin</PRE>

quit

 

 

#wget http://apache.tt.co.kr/spamassassin/source/Mail-SpamAssassin-3.2.4.tar.gz

#tar zxvf Mail-SpamAssassin-3.2.4.tar.gz

#cd Mail-SpamAssassin-3.2.4

[root@localhost Mail-SpamAssassin-3.2.4]# perl Makefile.PL && make && make install

#cd rules

 

#cp -f user_prefs /etc/mail/spamassassin/

#cp -f local.cf /etc/mail/spamassassin/

#cd ../spamd

#cp redhat-rc-script.sh /etc/rc.d/init.d/spamd

#chkconfig add spamd

#chkconfig spamd on

 

Spamd 데몬 옵션 설정

 

vi /etc/sysconfig/spamassassin

SPAMDOPTIONS="-d -c -m5 -H -u vpopmail -L -x"

 

-d : 데몬모드

-c : 유저 환경 설정 파일 설정

-m5 : 최대 자식 프로세스 숫자 5로 설정

-H : 다른 홈디렉터리 지정

-u : spamd vpopmail 유저 권한으로 실행

-L : Local 유저에 적용

-x : 사용자별 환경설정 무시

 

cat /etc/mail/spamassassin/local.cf (현재 서비스 돌고 있는 설정파일입니다.)

 

required_hits 5.0

whitelist_from *@도메인명

whitelist_to *@도메인명

rewrite_header Subject [SPAM]

report_safe      0

 

#   Use Bayesian classifier (default: 1)

#

use_bayes 1

bayes_path /home/spam/.spamassassin/bayes

auto_whitelist_path /home/spam/.spamassassin/auto-whitelist

bayes_file_mode 777

auto_whitelist_file_mode 777

 

#   Bayesian classifier auto-learning (default: 1)

#

bayes_auto_learn 1

 

ok_locales      all

 

# SURBL Rule

score URIBL_AB_SURBL 4

score URIBL_OB_SURBL 4

score URIBL_PH_SURBL 4

score URIBL_SC_SURBL 4

score URIBL_WS_SURBL 3

 

score SUSPICIOUS_RECIPS 7.3

score RATWARE_EGROUPS 14.7

score DATE_SPAMWARE_Y2K 6.8

score MSGID_RANDY 6.9

score MSGID_YAHOO_CAPS 13

score FORGED_MUA_OUTLOOK 8.8

score RCVD_HELO_IP_MISMATCH 9.7

score FORGED_HOTMAIL_RCVD2 15

score FORGED_MUA_AOL_FROM 15

score FORGED_MUA_EUDORA 15

score FORGED_MUA_IMS 15

score FORGED_YAHOO_RCVD 15

score FORGED_MUA_OUTLOOK 10

score INVALID_MSGID 20

score FORGED_OUTLOOK_TAGS 10

score BIZ_TLD 7.3

score HELO_DYNAMIC_IPADDR2 3.1

score DRUGS_ERECTILE 13

score INFO_TLD 16

score PLING_PLING 7.4

 

#Rules for all senders

 

score UPPERCASE_25_50 0.5

score UPPERCASE_50_75 0.5

score UPPERCASE_75_100 0.5

 

#General rules for html-based mail & html-based bulk mail

score HTML_MESSAGE 1.8

#General rules for html-based bulk messages

score MIME_HTML_ONLY 2.1

 

#Ordinary rules for spamers & internet via e-mail

#& bulk mail

score HTML_FONT_BIG 0.6

score HTML_FONT_INVISIBLE 1.2

 

score EXTRA_MPART_TYPE 0.9

score NO_REAL_NAME 0.8

 

#Very strong rules for spamers

score DATE_IN_FUTURE_12_24 5.0

score DATE_IN_FUTURE_06_12 5.0

score DATE_IN_FUTURE_03_06 5.0

score DATE_IN_PAST_96_XX 5.0

score DATE_IN_PAST_03_06 5.0

score DATE_IN_PAST_12_24 5.0

score INVALID_DATE 5.0

score HTML_TITLE_UNTITLED 5.0

score MISSING_MIMEOLE 5.0

score FORGED_HOTMAIL_RCVD 5.0

score RCVD_FAKE_HELO_DOTCOM 5.0

score KOREAN_UCE_SUBJECT 2.4

 

#한글 폰트 설정때문에 스팸메일의 의심을 받게 되는것을 막기 위한 설정

score HTML_FONT_FACE_BAD 0.0

 

# Empty message

rawbody __SOMETHING     /\S/

meta    BODY_EMPTY      !__SOMETHING

score   BODY_EMPTY      2.606

 

# http 주소 뒤에 포트번호가 있을 경우

uri     MY_HTTP_ODD_PORT        /\w+\.(com|net|info|biz):\d+ /i

describe        MY_HTTP_ODD_PORT        Link to a server on nonstandard port

score   MY_HTTP_ODD_PORT        2.0

 

# URL이 숫자로만 돼있는 경우

uri     MY_DOMAIN_NUMBERS_ONLY  /[.\/@]+\.(com|net|biz|info)/i

describe        MY_DOMAIN_NUMBERS_ONLY  Domain names has numbers only

score   MY_DOMAIN_NUMBERS_ONLY  2.0

 

 

 

7. qmail-scanner 1.24 설치

스캐너는 clamdscanverbose_spamassassin을 연동시킬 것입니다.

 

혹시 라도 setuidperl의 퍼미션을 확인해보고 아래와 다르면 바꿔준다.

[root@localhost root]# chown root /usr/bin/suidperl

[root@localhost root]# chmod 4711 /usr/bin/suidperl

 

[root@localhost qmail-scanner-1.24]# cp -r locale/en_GB locale/eucKR

 

# configure

./configure \

--spooldir /var/spool/qmailscan \

--qmaildir /var/qmail \

--bindir /var/qmail/bin \

--qmail-queue-binary /var/qmail/bin/qmail-queue  \

--admin root \

--notify none \

--silent-viruses auto \

--debug 0 \

--unzip 1 \

--add-dscr-hdrs 0 \

--archive 0 \

--redundant no \

--log-details  syslog \

--fix-mime 1  \

--scanners verbose_spamassassin,clamdscan \

 

# 설치

./configure \

--spooldir /var/spool/qmailscan \

--qmaildir /var/qmail \

--bindir /var/qmail/bin \

--qmail-queue-binary /var/qmail/bin/qmail-queue  \

--admin root \

--notify none \

--silent-viruses auto \

--debug 0 \

--unzip 1 \

--add-dscr-hdrs 0 \

--archive 0 \

--redundant no \

--log-details  syslog \

--fix-mime 1  \

--scanners verbose_spamassassin,clamdscan \

--install

 

cp -f quarantine-attachments.txt /var/spool/qmailscan/

chown qscand.qscand /var/spool/qmailscan/quarantine-attachments.txt

chmod 660 /var/spool/qmailscan/quarantine-attachments.txt

chown qscand.qscand  /var/qmail/bin/qmail-scanner-queue.pl

chmod 4755 /var/qmail/bin/qmail-scanner-queue.pl

/var/qmail/bin/qmail-scanner-queue.pl g 반드시 해줘야 qmail-scanner 디비가 갱신됩니다.

 

vi /var/qmail/supervise/qmail-smtpd/run

 

export QMAILQUEUE="/var/qmail/bin/qmail-scanner-queue.pl" 추가

 

vi ~vpopmail/etc/tcp.smtp

# No Qmail-Scanner at all for mail from 127.0.0.1

127.0.0.1:allow,RELAYCLIENT="",QMAILQUEUE="/var/qmail/bin/qmail-queue"

 

# Use Qmail-Scanner without SpamAssassin on any mail from the local network

# [it triggers SpamAssassin via the presence of the RELAYCLIENT var]

192.168.100.:allow,RELAYCLIENT="",QMAILQUEUE="/var/qmail/bin/qmail-queue"

 

# Use Qmail-Scanner with SpamAssassin on any mail from the rest of the world

:allow

 

참고로 tcp.smtp QMAILQUEUE 설정을 추가하여 테스트 해보니

127.0.0.1 192.168.100.0/24 대역은 SMTP를 통해 메일을 보낼 때 qmail-scanner가 적용이 안됩니다. QMAILQUEUE 설정이 빠져 있으면 로컬 네트워커의 유저들이 메일을 보낼때도 필터링이 적용됩니다.

 

/etc/rc.d/init.d/qmail restart

/usr/local/src/qmail-filterling/qmail-scanner-1.25/contrib/test_installation.sh -doit

 

만약 Spamassassin에서 제목에 스팸문구가 안붙어 들어오면

vi /var/qmail/bin/qmail-scanner-queue.pl

my $spamc_subject='[SPAM]'; 스팸문구 설정

 

마지막으로 스팸필터링이 제대로 구동되는지 테스트를 해봅니다.

 

실제 스팸메일로 걸러진 메일의 헤더를 보면 아래와 같이 나옵니다.

 

<PRE>Received: from 207.144.10.98 by 메일서버도메인명 (envelope-from <qitycgpg@msn.com>, uid 508) with qmail-scanner-1.24 </PRE><PRE> (clamdscan: 0.92/5921. spamassassin: 3.2.4.  </PRE><PRE> Clear:RC:0(207.144.10.98):SA:1(16.0/5.0):. </PRE><PRE> Processed in 2.136584 secs); 03 Mar 2008 01:12:07 -0000</PRE><PRE>X-Spam-Flag: YES</PRE><PRE>X-Spam-Checker-Version: SpamAssassin 3.2.4 (2008-01-01) on 메일서버도메인명</PRE><PRE>X-Spam-Level: ****************</PRE><PRE>X-Spam-Status: Yes, score=16.0 required=5.0 tests=BAYES_99,FH_HELO_EQ_610HEX,</PRE><PRE>        FRT_PENIS1,RDNS_NONE,SARE_ADLTSUB2,SARE_ADULT2,SARE_OBFUMONEY2,SARE_SUB_PENIS,</PRE><PRE>        UNPARSEABLE_RELAY autolearn=spam version=3.2.4</PRE><PRE>X-Spam-Report: </PRE><PRE>        *  3.5 BAYES_99 BODY: Bayesian spam probability is 99 to 100%</PRE><PRE>        *      [score: 1.0000]</PRE><PRE>        *  4.1 FH_HELO_EQ_610HEX Helo is 6-10 hex chr's.</PRE><PRE>        *  1.2 SARE_ADLTSUB2 Contains possible adult words</PRE><PRE>        *  1.7 SARE_SUB_PENIS subject has likely spammer phrase or word</PRE><PRE>        *  0.0 UNPARSEABLE_RELAY Informational: message has unparseable relay lines</PRE><PRE>        *  3.0 FRT_PENIS1 BODY: ReplaceTags: Penis</PRE><PRE>        *  1.4 SARE_ADULT2 BODY: Contains adult material</PRE><PRE>        *  1.0 SARE_OBFUMONEY2 BODY: masked spam word(s)</PRE><PRE>        *  0.1 RDNS_NONE Delivered to trusted network by a host with no rDNS</PRE>

 

큐메일스캐너와 스팸어쌔신을 적용해서 사용하고 있는데 완벽하진 않지만 80~90% 정도는 스팸메일을 잡아내고 있습니다.

 

이 문서를 읽고 발생한 책임에 대해서는 본인은 책임지지 않으며 각자 알아서 판단하고 적용해 보세요

반응형