CentOS4.4下邮件服务器架设笔记之基本功能实现
http://yanweihu.blog.51cto.com
1。安装centos4.4,安装时只选择一个"开发工具"的包,其它都不勾选,安装完毕;
2。配置yum更新库:
[root@mail]# vi /etc/yum.repos.d/dag.repo
[dag]
name=Dag RPM Repository for Red Hat Enterprise Linux
baseurl=http://apt.sw.be/redhat/el$releasever/en/$basearch/dag
http://mirror.be10.com/centos/$releasever/os/$basearch/
http://centos.hostlink.com.hk/$releasever/os/$basearch/
http://ftp.hostrino.com/pub/centos/
gpgcheck=1
enabled=1
[root@mail]# rpm --import http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt
还有一个导入:(此处暂不导入)
[root@mail]# rpm --import http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-4
3。解决putty连接显示乱码:
vi /etc/sysconfig/i18n将里面内容替换成下面;
LANG="en_US:en"
SUPPORTED="en_US:en:en_US:zh:en_US.en:en_US:en"
SYSFONT="latarcyrheb-sun16"
4。关闭cups(打印服务),
[root@mail log]# /etc/rc.d/init.d/cups stop
Stopping cups: [ OK ]
[root@mail log]# chkconfig cups off
[root@mail log]#
5。解决时间同步问题:
[root@mail ~]# yum install ntp
Dependencies Resolved
=============================================================================
Package Arch Version Repository Size
=============================================================================
Installing:
ntp i386 4.2.0.a.20040617-6.el4 base 1.2 M
Transaction Summary
=============================================================================
Install 1 Package(s)
Update 0 Package(s)
Remove 0 Package(s)
Total download size: 1.2 M
Is this ok [y/N]: y
安装完毕后,就可以有ntpdatae命令了,可以使用ntpdate 命令进行同步了!否则没有ntpdate命令。
[root@mail /]# vi /etc/crontab
将下面:
01 * * * * root run-parts /etc/cron.hourly
02 4 * * * root run-parts /etc/cron.daily
22 4 * * 0 root run-parts /etc/cron.weekly
42 4 1 * * root run-parts /etc/cron.monthly
修改为:
#01 * * * * root run-parts /etc/cron.hourly
#02 4 * * * root run-parts /etc/cron.daily
#22 4 * * 0 root run-parts /etc/cron.weekly
#42 4 1 * * root run-parts /etc/cron.monthly
并添加命令行:意思是每隔三分钟与时钟服务器210.72.145.44同步一次时间
*/3 * * * * root /usr/sbin/ntpdate 210.72.145.44 > /dev/null 2>&1
改完后重启一下服务:
[root@mail /]# service crond restart
Stopping crond: [ OK ]
Starting crond: [ OK ]
[root@mail /]#
6.安装postfix,dovecot,apache,其中蓝色字体,是相依赖的包,绿色为安装的顺序;
查看域名MX记录
[root@mail postfix]# host -t mx centos.eb.cn
centos.eb.cn mail is handled by 10 mail.centos.eb.cn.
[root@mail etc]yum install postfix
[root@mail etc]yum install dovecot
Dependencies Resolved
=============================================================================
Package Arch Version Repository Size
=============================================================================
Installing:
dovecot i386 0.99.11-8.EL4 base 614 k
Installing for dependencies:
mysql i386 4.1.20-2.RHEL4.1 base 2.9 M
perl-DBI i386 1.58-2.el4.rf dag 819 k
perl-Net-Daemon noarch 0.43-1.el4.rf dag 44 k
perl-PlRPC noarch 0.2020-1.el4.rf dag 33 k
postgresql-libs i386 7.4.17-1.RHEL4.1 update 147 k
Transaction Summary
=============================================================================
Install 6 Package(s)
Update 0 Package(s)
Remove 0 Package(s)
Total download size: 4.5 M
Is this ok [y/N]: y
Downloading Packages:
(1/6): postgresql-libs-7. 16% |==== | 24 kB 00:39 ETA
Installing: perl-Net-Daemon ######################### [1/6]
Installing: perl-PlRPC ######################### [2/6]
Installing: perl-DBI ######################### [3/6]
Installing: mysql ######################### [4/6]
Installing: postgresql-libs ######################### [5/6]
Installing: dovecot ######################### [6/6]
[root@mail etc]yum install httpd
=============================================================================
Package Arch Version Repository Size
=============================================================================
Installing:
httpd i386 2.0.52-32.3.ent.centos4 update 888 k
Installing for dependencies:
apr i386 0.9.4-24.5.c4.2 base 88 k
apr-util i386 0.9.4-21 base 51 k
httpd-suexec i386 2.0.52-32.3.ent.centos4 update 29 k
Updating for dependencies:
initscripts i386 7.93.29.EL-1.centos4 base 1.1 M
Transaction Summary
=============================================================================
Install 4 Package(s)
Update 1 Package(s)
Remove 0 Package(s)
Total download size: 2.2 M
Downloading Packages:
(1/5): initscripts-7.93.2 9% |== | 112 kB 03:09 ETA
Running Transaction
Installing: apr ######################### [1/6]
Installing: apr-util ######################### [2/6]
Updating : initscripts ######################### [3/6]
Installing: httpd ######################### [4/6]
Installing: httpd-suexec ######################### [5/6]
Cleanup : initscripts ######################### [6/6]
7。POSTFIX的配置方法:
[root@mail /]# cd /etc/postfix
[root@mail postfix]# cp main.cf main.cf.bak
[root@mail postfix]# vi main.cf修改如下面所示:粉色字为待修改,绿色为修改后)
#myhostname = host.domain.tld
myhostname = mail.centos.eb.cn
#mydomain = domain.tld
mydomain = centos.eb.cn
#myorigin = $mydomain
myorigin = $mydomain
inet_interfaces = localhost
#inet_interfaces = localhost
inet_interfaces = all
mydestination = $myhostname, localhost.$mydomain, localhost
#mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
#mydestination = $myhostname, localhost.$mydomain, localhost
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
#relay_domains = $mydestination
relay_domains = $mydestination
#mynetworks = 168.100.189.0/28, 127.0.0.0/8
mynetworks = 10.0.0.0/8, 127.0.0.0/8
#home_mailbox = Maildir/
home_mailbox = Maildir/
#smtpd_banner = $myhostname ESMTP $mail_name
#smtpd_banner = $myhostname ESMTP $mail_name ($mail_version)
smtpd_banner = $myhostname ESMTP mailserver maintanace by ---Weihu.Yan---
(此段追加在文件结尾)
#append smtp auth config
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain = $myhostname
smtpd_sasl_security_options = noanonymous
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
message_size_limit = 20971520 (表附件大小为20M,20*1024*1024)
配置SMTP认证:
[root@mail postfix]# vi /usr/lib/sasl2/smtpd.conf修改如下:
pwcheck_method: saslauthd
#pwcheck_method: saslauthd
pwcheck_method: auxprop (表示不使用系统用户认证)
[root@mail postfix]# vi /etc/sysconfig/saslauthd
MECH=shadow 找到这一行,在前面加#
#MECH=shadow
FLAGS= 找到此行,在等号后面添加“sasldb”
FLAGS=sasldb 定义认证方式为sasldb2
建立用户邮箱模板:
[root@mail postfix]# mkdir /etc/skel/Maildir
[root@mail postfix]# chmod 700 /etc/skel/Maildir
若已有用户,刚为已存在用户建立邮箱的方法如下:
[root@mail ~]# mkdir /home/leeki.yan/Maildir 为用户(这里以leeki.yan用户为例)建立邮箱目录
[root@mail ~]# chmod 700 /home/leeki.yan/Maildir 设置该用户邮箱目录属性为700
[root@mail ~]# chown leeki.yan. /home/leeki.yan/Maildir 设置该用户邮箱目录为该用户所有
为用户设置SMTP密码:(以root账户为例)
[root@mail postfix]# saslpasswd2 -u mail.centos.eb.cn -c root
Password:
Again (for verification):
[root@mail postfix]#
改变SASL的归属
[root@mail postfix]# chgrp postfix /etc/sasldb2
[root@mail postfix]# chmod 640 /etc/sasldb2
关闭sendmail,及设置不自动启动,并修改默认的MTA
[root@mail postfix]# /etc/rc.d/init.d/sendmail stop
Shutting down sendmail: [ OK ]
Shutting down sm-client: [ OK ]
[root@mail postfix]# chkconfig sendmail off
[root@mail postfix]# chkconfig --list sendmail
sendmail 0:off 1:off 2:off 3:off 4:off 5:off 6:off
[root@mail postfix]# alternatives --config mta
There are 2 programs which provide 'mta'.
Selection Command
-----------------------------------------------
*+ 1 /usr/sbin/sendmail.sendmail
2 /usr/sbin/sendmail.postfix
Enter to keep the current selection[+], or type selection number: 2
[root@mail postfix]#
启动SMTP认证及Postfix服务,并设置相应服务为自启动
[root@mail postfix]# chkconfig saslauthd on
[root@mail postfix]# chkconfig --list saslauthd
saslauthd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@mail postfix]# chkconfig postfix on
[root@mail postfix]# chkconfig --list postfix
postfix 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@mail postfix]# /etc/rc.d/init.d/saslauthd start
Starting saslauthd: [ OK ]
[root@mail postfix]# /etc/rc.d/init.d/postfix start
Starting postfix: [ OK ]
[root@mail postfix]#
查看smtp端口是否为打开
[root@mail postfix]# netstat -tl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 *:809 *:* LISTEN
tcp 0 0 *:sunrpc *:* LISTEN
tcp 0 0 *:ssh *:* LISTEN
tcp 0 0 *:smtp *:* LISTEN
[root@mail postfix]#
8。配置dovecot
[root@mail etc]# vi /etc/dovecot.conf(修改如下面所示:粉色字为待修改,绿色为修改后)
#protocols = imap imaps
protocols = imap imaps pop3 pop3s
#default_mail_env =
default_mail_env = maildir:~/Maildir (定义邮箱的目录)
[root@mail etc]# vi /etc/sysconfig/iptables
添加以下部分:
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 110 -j ACCEPT 为pop3
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 143 -j ACCEPT 为imap
[root@mail etc]# /etc/rc.d/init.d/iptables restart
Flushing firewall rules: [ OK ]
Setting chains to policy ACCEPT: filter [ OK ]
Unloading iptables modules: [ OK ]
Applying iptables firewall rules: [ OK ]
[root@mail etc]#
[root@mail etc]# chkconfig dovecot on
[root@mail etc]# chkconfig --list dovecot
dovecot 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@mail etc]# /etc/rc.d/init.d/dovecot start
Starting Dovecot Imap: [ OK ]
[root@mail etc]#
至此可以测试收发,邮箱服务器的基本功能已实现!
[root@mail etc]# useradd leeki.yan -s /sbin/nologin
[root@mail etc]# passwd leeki.yan
Changing password for user leeki.yan.
New UNIX password:
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
添加用户测试看看吧!
CentOS4.4下邮件服务器架设笔记之SPAM与防毒功能实现
通过上一篇“CentOS4.4下邮件服务器架设笔记之基本功能实现”,至此,我们已经拥有一台可以正常收发MAIL的服务器了,但其功能较少,不具备防毒,防垃圾功效。本篇主要实现添加此功能!且添加了对邮件流量的监控功能!
1.安装clamav防病毒软件;
[root@mail ~]# yum install clamav
Dependencies Resolved
=============================================================================
Package Arch Version Repository Size
=============================================================================
Installing:
clamav i386 0.91.2-1.el4.rf dag 1.1 M
Installing for dependencies:
clamav-db i386 0.91.2-1.el4.rf dag 10 M
Transaction Summary
=============================================================================
Install 2 Package(s)
Update 0 Package(s)
Remove 0 Package(s)
Total download size: 11 M
Is this ok [y/N]: y
Downloading Packages:
Downloading Packages:
(1/2): clamav-0.91.2-1.el 100% |=========================| 1.1 MB 02:31
(2/2): clamav-db-0.91.2-1 100% |=========================| 10 MB 21:27
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing: clamav-db ######################### [1/2]
Installing: clamav ######################### [2/2]
Installed: clamav.i386 0:0.91.2-1.el4.rf
Dependency Installed: clamav-db.i386 0:0.91.2-1.el4.rf
Complete!
上面clamav也可手工下载到:
http://www.baxitek.com/pub/clamav/
wget http://www.baxitek.com/pub/clamav/clamav-db-0.91.2-1.i386.rpm
wget http://www.baxitek.com/pub/clamav/clamav-0.91.2-1.i386.rpm
2.更新杀毒软件病毒定义;
[root@mail ~]# /usr/bin/freshclam
ClamAV update process started at Fri Aug 31 18:55:00 2007
Downloading daily.cvd [100%]
daily.cvd updated (version: 4110, sigs: 16448, f-level: 21, builder: acab)
Database updated (149611 signatures) from db.cn.clamav.net (IP: 58.221.222.69)
WARNING: Clamd was NOT notified: Can't find or parse configuration file /etc/clamd.conf
3.鉴于上面升级病毒码的警告信息:是因为通过yum RPM包方式安装的clamav时,所生成的配置文件,不在/etc目录下,且文件名叫clamav.conf,按下面操作:
[root@mail etc]# find / -name clam*
find: /proc/801/task: No such file or directory
find: /proc/802/task: No such file or directory
find: /proc/803/task: No such file or directory
find: /proc/928/task: No such file or directory
find: /proc/936/task: No such file or directory
/etc/log.d/conf/services/clamav.conf
[root@mail etc]# cp /etc/log.d/conf/services/clamav.conf /etc/clamd.conf
4.安装spamassassin防垃圾软件;
[root@mail ~]# yum -y install spamassassin
Dependencies Resolved
=============================================================================
Package Arch Version Repository Size
=============================================================================
Installing:
spamassassin i386 3.2.3-1.el4.rf dag 1.0 M
Installing for dependencies:
perl-Archive-Tar noarch 1.32-1.el4.rf dag 47 k
perl-Digest-HMAC noarch 1.01-13 base 11 k
perl-Digest-SHA1 i386 2.07-5 base 19 k
perl-IO-Socket-SSL noarch 1.07-2.el4.rf dag 43 k
perl-IO-Zlib noarch 1.05-1.el4.rf dag 15 k
perl-Net-DNS i386 0.61-1.el4.rf dag 271 k
perl-Net-IP noarch 1.25-1.el4.rf dag 30 k
perl-Net-SSLeay i386 1.30-4.el4.centos extras 198 k
perl-Time-HiRes i386 1.55-3 base 22 k
Updating for dependencies:
perl-HTML-Parser i386 3.55-1.el4.rf dag 140 k
Transaction Summary
=============================================================================
Install 10 Package(s)
Update 1 Package(s)
Remove 0 Package(s)
Total download size: 1.8 M
Downloading Packages:
(1/11): perl-HTML-Parser- 100% |=========================| 140 kB 00:24
(2/11): perl-Digest-HMAC- 100% |=========================| 11 kB 00:05
(3/11): perl-Net-DNS-0.61 100% |=========================| 271 kB 00:35
(4/11): perl-Net-SSLeay-1 100% |=========================| 198 kB 00:06
(5/11): perl-Digest-SHA1- 100% |=========================| 19 kB 00:04
(6/11): perl-Net-IP-1.25- 100% |=========================| 30 kB 00:06
(7/11): perl-Time-HiRes-1 100% |=========================| 22 kB 00:04
(8/11): perl-IO-Socket-SS 100% |=========================| 43 kB 00:06
(9/11): perl-Archive-Tar- 100% |=========================| 47 kB 00:07
(10/11): spamassassin-3.2 100% |=========================| 1.0 MB 02:19
(11/11): perl-IO-Zlib-1.0 100% |=========================| 15 kB 00:02
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing: perl-Digest-SHA1 ####################### [ 1/12]
Updating : perl-HTML-Parser ####################### [ 2/12]
Installing: perl-Digest-HMAC ####################### [ 3/12]
Installing: perl-IO-Zlib ####################### [ 4/12]
Installing: perl-Archive-Tar ####################### [ 5/12]
Installing: perl-Time-HiRes ####################### [ 6/12]
Installing: perl-Net-IP ####################### [ 7/12]
Installing: perl-Net-DNS ####################### [ 8/12]
Installing: perl-Net-SSLeay ####################### [ 9/12]
Installing: perl-IO-Socket-SSL ####################### [10/12]
Installing: spamassassin ####################### [11/12]
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LANG = "en_US.en"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LANG = "en_US.en"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
Cleanup : perl-HTML-Parser ####################### [12/12]
Installed: spamassassin.i386 0:3.2.3-1.el4.rf
Dependency Installed: perl-Archive-Tar.noarch 0:1.32-1.el4.rf perl-Digest-HMAC.noarch 0:1.01-13 perl-Digest-SHA1.i386 0:2.07-5 perl-IO-Socket-SSL.noarch 0:1.07-2.el4.rf perl-IO-Zlib.noarch 0:1.05-1.el4.rf perl-Net-DNS.i386 0:0.61-1.el4.rf perl-Net-IP.noarch 0:1.25-1.el4.rf perl-Net-SSLeay.i386 0:1.30-4.el4.centos perl-Time-HiRes.i386 0:1.55-3
Dependency Updated: perl-HTML-Parser.i386 0:3.55-1.el4.rf
Complete!
[root@mail ~]#
5.针对上面红色字体的告警信息,我们修改一下/etc/sysconfig/i18n文件,如果不修改在安装MailScanner时候,每次重新启动都提示,但是暂不知道有没有什么其它的影响!
[root@mail ~]# vi /etc/sysconfig/i18n
添加以下命令行:
LC_ALL="C"
并将:LANG="en_US.UTF-8"
改为:LANG="en_US"
6.接下来我们安装MailScanner,首先我们要下载,可以到官方网上下,地址:http://www.mailscanner.info/上下载。
[root@mail tmp]# wget http://www.mailscanner.info/files/4/rpm/MailScanner-4.62.9-3.rpm.tar.gz
--16:40:51-- http://www.mailscanner.info/files/4/rpm/MailScanner-4.62.9-3.rpm.tar.gz
=> `MailScanner-4.62.9-3.rpm.tar.gz'
Resolving http://www.mailscanner.info/... 81.17.252.15
Connecting to http://www.mailscanner.info/|81.17.252.15|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 4,239,584 (4.0M) [application/x-gzip]
100%[====================================>] 4,239,584 6.74K/s ETA 00:00
16:50:54 (6.88 KB/s) - `MailScanner-4.62.9-3.rpm.tar.gz' saved [4239584/4239584]
[root@mail tmp]# tar zxvf MailScanner-4.62.9-3.rpm.tar.gz #解压缩此包
[root@mail tmp]# cd MailScanner-4.62.9-3
[root@mail MailScanner-4.62.9-3]# ./install.sh #此过程较长,此时可以喝一杯去,哈哈!
Good. You have the patch command.
Good, you have /usr/src/redhat in place.
Writing a .rpmmacros file in your home directory to stop
unpackaged files breaking the build process.
You can delete it once MailScanner is installed if you want to.
Now to install MailScanner itself.
NOTE: If you get lots of errors here, run the install.sh script
NOTE: again with the command "./install.sh nodeps"
Preparing... ########################################### [100%]
1:mailscanner ########################################### [100%]
Good, SpamAssassin site rules found in /etc/mail/spamassassin
To activate MailScanner run the following commands:
service sendmail stop
chkconfig sendmail off
chkconfig --level 2345 MailScanner on
service MailScanner start
For technical support, please read the MAQ at www.mailscanner.biz/maq/
and buy the book at www.mailscanner.info/store
----------------------------------------------------------
Please buy the MailScanner book from http://www.mailscanner.info/!
It is a very useful administration guide and introduction
to MailScanner. All the proceeds go directly to making
MailScanner a better supported package than it is today.
7.配置MainScanner及设置POSTFIX使用MailScanner调用clamav及SA;(红色字为待修改,绿色为修改后的内容.
[root@mail MailScanner-4.62.9-3]# vi /etc/MailScanner/MailScanner.conf
%org-name% = yoursite
%org-name% = centosmail
%org-long-name% = Your Organisation Name Here
%org-long-name% = CentosMail_Leeki.Yan
%web-site% = http://www.your-organisation.com/
%web-site% = http://www.centos.eb.cn/
Run As User =
Run As User = postfix
Run As Group =
Run As Group = postfix
Incoming Queue Dir = /var/spool/mqueue.in
Incoming Queue Dir = /var/spool/postfix/hold
Outgoing Queue Dir = /var/spool/mqueue
Outgoing Queue Dir = /var/spool/postfix/incoming
MTA = sendmail
MTA = postfix
Virus Scanners = auto
Virus Scanners = clamav
Always Include SpamAssassin Report = no
Always Include SpamAssassin Report = yes
SpamAssassin User State Dir =
SpamAssassin User State Dir = /var/spool/MailScanner/spamassassin
Incoming Work User =
Incoming Work Group =
Incoming Work User = postfix
Incoming Work Group = postfix
SpamAssassin Install Prefix =
SpamAssassin Install Prefix = /usr/bin
Quarantine User =
Quarantine Group =
Quarantine User = postfix
Quarantine Group = postfix
[root@mail MailScanner-4.62.9-3]# vi /etc/MailScanner/MailScanner.conf
[root@mail MailScanner-4.62.9-3]# cd /var/spool/MailScanner/
[root@mail MailScanner]# ls -al
total 20
drwxr-xr-x 4 root root 4096 Aug 31 20:34 .
drwxr-xr-x 16 root root 4096 Aug 31 20:34 ..
drwxr-xr-x 8 root root 4096 Aug 31 21:01 incoming
drwxr-xr-x 2 root root 4096 Aug 31 20:34 quarantine
[root@mail MailScanner]# mkdir spamassassin
[root@mail MailScanner]# mkdir .spamassassin
[root@mail MailScanner]# chown -R postfix:postfix /var/spool/MailScanner/*
[root@mail MailScanner]# ls -al
total 28
drwxr-xr-x 6 root root 4096 Aug 31 21:48 .
drwxr-xr-x 16 root root 4096 Aug 31 20:34 ..
drwxr-xr-x 2 root root 4096 Aug 31 21:48 .spamassassin
drwxr-xr-x 8 postfix postfix 4096 Aug 31 21:01 incoming
drwxr-xr-x 2 postfix postfix 4096 Aug 31 20:34 quarantine
drwxr-xr-x 2 postfix postfix 4096 Aug 31 21:48 spamassassin
修改main.cf文件,让其使用MainScanner;
[root@mail MailScanner]# vi /etc/postfix/main.cf
将: #header_checks = regexp:/etc/postfix/header_checks
改为:header_checks = regexp:/etc/postfix/header_checks
[root@mail MailScanner]# mv /etc/postfix/header_checks /etc/postfix/header_checks.bak
[root@mail MailScanner]# vi /etc/postfix/header_checks
增加如下命令:
(注意,空格处要使用 tab 键,添加如下内容)
/^Received:/ HOLD
[root@mail MailScanner]# chkconfig spamassassin on
[root@mail MailScanner]# service spamassassin start
Starting spamd: [ OK ]
[root@mail MailScanner]#
[root@mail MailScanner]# chkconfig postfix off #关闭postfix自启动,因MailScanner启动时,自动启动postfix
[root@mail MailScanner]# chkconfig MailScanner on
[root@mail MailScanner]# /etc/rc.d/init.d/MailScanner start
Starting MailScanner daemons:
incoming postfix: [ OK ]
outgoing postfix: [ OK ]
MailScanner: [ OK ]
查看clamav有没有启动,使用下面命令:
[root@mail MailScanner]# ps -aux | grep clamd
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.3/FAQ
root 12603 0.0 0.2 2992 444 pts/0 S+ 22:08 0:00 grep clamd
8.重新启动一下机器,开始测试吧!
[root@mail~]#tail -f /var/log/maillog
开始测试发一封邮件,可以在日志中查到到以下内容:
Aug 31 22:23:18 mail MailScanner[2600]: Using locktype = flock
Aug 31 22:23:18 mail MailScanner[3338]: Using SpamAssassin results cache
Aug 31 22:23:18 mail MailScanner[3338]: Connected to SpamAssassin cache database
Aug 31 22:23:18 mail MailScanner[3338]: Enabling SpamAssassin auto-whitelist functionality...
Aug 31 22:23:33 mail MailScanner[2709]: Using locktype = flock
Aug 31 22:23:36 mail MailScanner[3264]: Using locktype = flock
Aug 31 22:23:38 mail MailScanner[3336]: Using locktype = flock
Aug 31 22:23:39 mail MailScanner[3338]: Using locktype = flock
Aug 31 22:24:13 mail pop3-login: Login: leeki.yan [::ffff:10.0.0.25]
Aug 31 22:25:39 mail postfix/smtpd[3345]: connect from unknown[10.0.0.25]
Aug 31 22:25:39 mail postfix/smtpd[3345]: C38C71702CA: client=unknown[10.0.0.25]
Aug 31 22:25:40 mail postfix/cleanup[3348]: C38C71702CA: hold: header Received: from ts (unknown [10.0.0.25])??by mail.centos.eb.cn (Postfix) with SMTP id C38C71702CA??for <leeki.yan@centos.eb.cn>; Fri, 31 Aug 2007 22:25:39 +0800 (CST) from unknown[10.0.0.25]; from=<leeki.yan@centos.eb.cn> to=<leeki.yan@centos.eb.cn> proto=SMTP helo=<ts>
Aug 31 22:25:40 mail postfix/cleanup[3348]: C38C71702CA: message-id=<001901c7ebdb$f70f9ff0$1900000a@triumph>
Aug 31 22:25:40 mail postfix/smtpd[3345]: disconnect from unknown[10.0.0.25]
Aug 31 22:25:43 mail MailScanner[3264]: New Batch: Scanning 1 messages, 934 bytes
Aug 31 22:25:59 mail pop3-login: Login: leeki.yan [::ffff:10.0.0.25]
Aug 31 22:25:59 mail MailScanner[3264]: Virus and Content Scanning: Starting
Aug 31 22:26:14 mail MailScanner[3264]: Requeue: C38C71702CA.8937F to 14A741702E8
Aug 31 22:26:14 mail MailScanner[3264]: Uninfected: Delivered 1 messages
Aug 31 22:26:14 mail postfix/qmgr[2579]: 14A741702E8: from=<leeki.yan@centos.eb.cn>, size=1212, nrcpt=1 (queue active)
Aug 31 22:26:14 mail postfix/local[3361]: 14A741702E8: to=<leeki.yan@centos.eb.cn>, relay=local, delay=35, status=sent (delivered to maildir)
Aug 31 22:26:14 mail postfix/qmgr[2579]: 14A741702E8: removed
Aug 31 22:28:29 mail pop3-login: Login: leeki.yan [::ffff:10.0.0.25]
从上面的日志可以看出,MailScanner已经开始起作用了!
9.另MailScanner.conf配置文件其它参数说明:
a.用mailscanner发信自动带加上这个内容:
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean
取消这种设置方法:vi /etc/MailScanner/MailScaner.conf
Sign Clean Messages = yes
改成
Sign Clean Messages = no
b.可以从网上找个翻译过的report中文文件,以后当发生警告时,就会发中文的告警信息;
mv cn /etc/MailScanner/reports即可
/etc/MailScanner/reports/en
因为部分中文没有,所有LOG里有报错:
方法:
cd /etc/MailScanner/reports/cn
cp ../en/* ../cn
当提示覆盖时,选n即可!
c.设置本地域不进行扫描:
编辑/etc/MailScanner/MailScanner.conf文件,
修改 Is Definitely Not Spam = /etc/MailScanner/rules/spam.whitelist.rules
vi /etc/MailScanner/rules/spam.whitelist.rules
加入 From: *@centos.eb.cn yes #centos.eb.cn是本地域名
重启MailScannerl。
在/etc/mail/spamassassin/local.cf里面加了一句whitelist_from *@trinet.com.cn
这样发出去的邮件都不会被标记为 spam ,但是还是经过了检查的,我想在问下,这两种设置的区别在那里 ?
答:设置whitelist_from,实际上还是会进行spam检查,whitelist_from 是表示在分数方面 -100分
而设置spam.whitelist.rules是直接标记不是垃圾邮件,不再进行spam检查的。
d.
Max Children = 5 #
这是设置 MailScanner 的进程数,如果你的计算机不够强劲的话,建议你将数值设小点,因为 MailScanner 比较耗资
源,尤其是内存
e.Virus Scanner Timeout = 30 # 病毒查杀软件扫描你的邮件的最长时间
f.Find Phishing Fraud = yes # 是否开启防钓鱼邮件检测功能
g.
Filename Rules = %etc-dir%/filename.rules.conf
Filetype Rules = %etc-dir%/filetype.rules.conf # 这两个参数用来设置你的邮件系统能接收或发送何种名称的附件
h.
Max SpamAssassin Size = 1024k # 设置 spamassassin 只能扫描最大为多少的邮件
i:
Syslog Facility = mail
Log Speed = no
Log Spam = no
Log Non Spam = no
Log Permitted Filenames = no
Log Permitted Filetypes = no
Log Silent Viruses = no
Log Dangerous HTML Tags = no # 上面这些参数是设置 MailScanner 是否在 maillog 日志中记录相关的信息。如果你的计算机不够强劲的 话,建议你还是选 no 吧。
10.安装mailscanner-mrtg监控邮件的流量;
[root@mail tmp]# wget http://nchc.dl.sourceforge.net/sourceforge/mailscannermrtg/mailscanner-mrtg-0.10.00-1.noarch.rpm
[root@mail tmp]# rpm -ivh mailscanner-mrtg-0.10.00-1.noarch.rpm
warning: mailscanner-mrtg-0.10.00-1.noarch.rpm: V3 DSA signature: NOKEY, key ID e342f442
error: Failed dependencies:
mrtg >= 2.9 is needed by mailscanner-mrtg-0.10.00-1.noarch
Suggested resolutions:
/home/buildcentos/CENTOS/en/4.0/i386/CentOS/RPMS/mrtg-2.10.15-1.i386.rpm
出现上面的报错,这是包依赖的原因,接下来先安装mrtg,再安装mailscanner-mrtg
[root@mail tmp]# yum -y install mrtg
Dependencies Resolved
=============================================================================
Package Arch Version Repository Size
=============================================================================
Installing:
mrtg i386 2.10.15-1 base 914 k
Installing for dependencies:
gd i386 2.0.28-5.4E base 119 k
Transaction Summary
=============================================================================
Install 2 Package(s)
Update 0 Package(s)
Remove 0 Package(s)
Total download size: 1.0 M
Downloading Packages:
(1/2): gd-2.0.28-5.4E.i38 100% |=========================| 119 kB 02:48
(2/2): mrtg-2.10.15-1.i38 100% |=========================| 914 kB 13:02
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing: gd ######################### [1/2]
Installing: mrtg ######################### [2/2]
Installed: mrtg.i386 0:2.10.15-1
Dependency Installed: gd.i386 0:2.0.28-5.4E
Complete!
再次安装mailscanner-mrtg,发现可以安装了,见下面:
[root@mail tmp]# rpm -ivh mailscanner-mrtg-0.10.00-1.noarch.rpm
warning: mailscanner-mrtg-0.10.00-1.noarch.rpm: V3 DSA signature: NOKEY, key ID e342f442
Preparing... ########################################### [100%]
1:mailscanner-mrtg ########################################### [100%]
Running MRTG to get your initial graphs (Could be slow)
Stopping httpd: [FAILED]
Starting httpd: httpd: Could not determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
[ OK ]
备注:在安装好mailscanner-mrtg后,发现maillog里面总报如下错误;
Oct 25 15:20:02 mailgate MailScanner-MRTG[5072]: ERROR: Snmpwalk Binary
specified in /etc/MailScanner/mailscanner-mrtg.conf is not executable
or not present. Maybe you need to install the snmp or snmp-utils
packages. See the README.SNMP file in the docs. - Skipping snmp
functions
Oct 25 15:20:02 mailgate MailScanner-MRTG[5072]: Unable to find a
mountpoint for /var/spool. Please set Spool Directory in mailscanner-
mrtg.conf to a valid mountpoint. You can see a list of mointpoints on
your system by using the df command.
Oct 25 15:20:02 mailgate MailScanner-MRTG[5072]: Unable to find a
mountpoint for /var/spool/MailScanner/incoming. Please set MailScanner
Work Directory in mailscanner-mrtg.conf to a valid mountpoint. You can
see a list of mointpoints on your system by using the df command
侦对上面的错误:(因为没有安装snmp包,所以CPU,MEM等图标就为空了)
vi /etc/Mailscanner/mailscanner-mrtg.conf
将
Use SNMP = yes
Snmpwalk Binary = /usr/bin/snmpwalk
MailScanner Work Directory = /var/spool/MailScanner/incoming
Spool Directory = /var/spool
修改为:
#Use SNMP = yes
#Snmpwalk Binary = /usr/bin/snmpwalk
MailScanner Work Directory = /
Spool Directory = /
11.配置apache自启动及mailscanner-mrtg参数修改(上一篇文章已经安装了apache)
[root@mail tmp]#chkconfig httpd on
[root@mail tmp]# vi /etc/MailScanner/mailscanner-mrtg.conf
MTA = sendmail
MTA = postfix
Incoming Queue Dir = /var/spool/mqueue.in/ # Sendmail
Incoming Queue Dir = /var/spool/postfix/hold/ # Postfix
Outgoing Queue Dir = /var/spool/mqueue/ # Sendmail
Outgoing Queue Dir = /var/spool/postfix/incoming/ # Sendmail
Interfaces to Monitor = eth0(此参数视情况而定修改,使用ifconfig -a查看后,再作决定)
例如本机就无需修改!见下面:蓝色字体
[root@mail tmp]# ifconfig -a
eth0 Link encap:Ethernet HWaddr 00:C0:A8:F5:06:CD
inet addr:10.6.6.111 Bcast:10.255.255.255 Mask:255.0.0.0
inet6 addr: fe80::2c0:a8ff:fef5:6cd/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:5950 errors:0 dropped:0 overruns:0 frame:0
TX packets:3547 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1585146 (1.5 MiB) TX bytes:463239 (452.3 KiB)
重新启动一下apache服务,然后在浏览器中输入http://邮件服务器的IP地址/mailscanner-mrtg/就可以看到流量图了!
12.其它的设定;
a.病毒库自动更新设定:
[root@mail tmp]# vi /etc/freshclam.conf
增加:LogFileMaxSize 2M
将#PidFile /var/run/freshclam.pid
改为:PidFile /var/run/freshclam.pid
[root@mail tmp]# crontab -e
0 */12 * * * /usr/bin/freshclam --quiet -l /var/log/clamav/freshclam.log 表每各12小时更新一次
b.设置spamassassin,支持CCERT中文垃圾邮件过滤规则集及自动更新
[root@mail tmp]# wget -N -P /usr/share/spamassassin www.ccert.edu.cn/spam/sa/Chinese_rules.cf
[root@mail tmp]# crontab -e
把下面一行复制到里面,进行自动更新规则
0 0 1 * * wget -N -P /usr/share/spamassassin www.ccert.edu.cn/spam/sa/Chinese_rules.cf; /etc/rc.d/init.d/spamassassin restart
# sa-learn --sync -D -p user_prefs (建立学习系统)
#sa-learn --dump all(查看自学习的数据信息)
13.至此防毒防垃圾功能都已实现,别特别注意一点:
MailScanner.conf中其中有一个参数
原始值:SpamAssassin Local Rules Dir =
此参数网上很多参考的文档设定为:
SpamAssassin Local Rules Dir =/etc/MailScanner
本人暂不推荐设定此参数,因为我在安装的时候发现,按照网上相关网关设定的后,邮件全部卡在队列里,日志里总重报如下信息,却没有报错信息,郁闷啊!
Aug 25 22:58:27 mail MailScanner[5619]: Using SpamAssassin results cache
Aug 25 22:58:27 mail MailScanner[5619]: Connected to SpamAssassin cache database
Aug 25 22:58:27 mail MailScanner[5619]: Enabling SpamAssassin auto-whitelist functionality...
Aug 25 22:58:30 mail MailScanner[5620]: MailScanner E-Mail Virus Scanner version 4.62.9 starting...
Aug 25 22:58:30 mail MailScanner[5620]: Read 794 hostnames from the phishing whitelist
Aug 25 22:58:30 mail MailScanner[5620]: SpamAssassin temporary working directory is /var/spool/MailScanner/incoming/SpamAssassin-Temp
Aug 25 22:58:32 mail MailScanner[5620]: Using SpamAssassin results cache
Aug 25 22:58:32 mail MailScanner[5620]: Connected to SpamAssassin cache database
Aug 25 22:58:32 mail MailScanner[5620]: Enabling SpamAssassin auto-whitelist functionality...
Aug 25 22:58:35 mail MailScanner[5626]: MailScanner E-Mail Virus Scanner version 4.62.9 starting...
Aug 25 22:58:35 mail MailScanner[5626]: Read 794 hostnames from the phishing whitelist
Aug 25 22:58:36 mail MailScanner[5626]: SpamAssassin temporary working directory is /var/spool/MailScanner/incoming/SpamAssassin-Temp
查看队列发现:无论是发信还是收信,邮件全部卡在队列里:测试发和收,都会被卡在队列里
[root@mail incoming]# mailq
-Queue ID- --Size-- ----Arrival Time---- -Sender/Recipient-------
695912341DA! 5535 Sat Aug 25 22:55:59 root@centos.eb.cn
root@centos.eb.cn
07D6B2341D8! 11042 Sat Aug 25 22:34:34 leeki.yan@centos.eb.cn
leeki.yan@centos.eb.cn
BEEBD2341D9! 2085 Sat Aug 25 23:00:58 leeki.yan@centos.eb.cn
leeki.yan@centos.eb.cn
-- 18 Kbytes in 3 Requests.
为此花掉三个日日夜夜排错!别提多惨啦!至此所需防毒防垃圾及流量监控都已实现!其它相关高级设定及优化,待总结。。。。
CentOS4.4下邮件服务器架设笔记之邮件网关功能实现
1.通过参考以上两篇文章:
CentOS4.4下邮件服务器架设笔记之基本功能实现
CentOS4.4下邮件服务器架设笔记之SPAM防毒功能实现
我们基本上实现了邮件收发,以及对垃圾邮件过滤的功能,但是目前面对企业来说,用microsoft exchange的比较多,我的想法,就是想要把这台邮件服务器的变成邮件网关,所有流进内部邮件服务器的邮件先经过MX GATEWAY扫描后,再往后面丢;虽然目前市面上很多这样功能的产品,但是价格却是一笔投资,但是LINUX却能容易做到;我在此写BLOG,把自己测试的情况与大家交流,相信对初学者是一个总结;
包括此篇文章的总结,也是花费我了将近一个月的时间抽空测试总结出来的,我希望以此作为抛砖引玉的功能,让大家把自己更好的总结给贡献出来!我自己是一个LINUX初学者,我想通过此平台认识更多的朋友,大家互相交流一下! QQ:418027712
2.转入正题:
首先介绍下我的内网测试环境:
a.参考上面两篇文档:分别架设服务器A,其IP地址:10.6.6.111;
b.新安装一台邮件服务器B,只包含(postfix+dovecot),没有垃圾过滤功能;来替代现实环境的exchange服务器,因为安装linux邮件服务器比microsoft平台的exchange快,简单,更重要的,找个古董机器都能装;
c.两台机器都是同一个域,centos.eb.cn
A机器名:mail.centos.eb.cn B机器名:mail1.cenots.eb.cn
http://blog.51cto.com/attachment/200709/200709301191138323937.jpg" border="0" />
3.开始配置:
a.配置邮件网关机器A,修改通过传输表实现转发;
即当邮件发给A机器时,A全部转发给B机器;
[root@mail ~]# cd /etc/postfix
[root@mail postfix]# vi main.cf
增加
transport_maps = hash:/etc/postfix/transport
然后保存退出,并编辑:
[root@mail postfix]# vi transport
增加
centos.eb.cn relay:[10.6.6.120]
保存退出后,执行:
[root@mail postfix]# postmap /etc/postfix/transport
[root@mail postfix]# postfix reload
postfix/postfix-script: refreshing the Postfix mail system
b.配置MailScanner.conf实现,当A机器对收到的外部邮件判断垃圾邮件时,丢到B机器的指定帐户spam@centos.eb.cn;
[root@mail postfix]# vi /etc/MailScanner/MailScanner.conf
#Spam Actions = deliver header "X-Spam-Status: Yes" #将此行的配置注释掉;
Spam Actions = forward spam@centos.eb.cn #转发指定账户配置
#High Scoring Spam Actions = deliver header "X-Spam-Status: Yes" #将此行的配置注释掉;
High Scoring Spam Actions = forward spam@centos.eb.cn #转发指定账户配置
重新启动一下MailScanner
[root@mail postfix]# service MailScanner restart
Shutting down MailScanner daemons:
MailScanner: [ OK ]
incoming postfix: [ OK ]
outgoing postfix: [ OK ]
Waiting for MailScanner to die gracefully ....................................................................... dead.
Starting MailScanner daemons:
incoming postfix: [ OK ]
outgoing postfix: [ OK ]
MailScanner: [ OK ]
[root@mail postfix]#
其实MailScanner在判定为垃圾邮件处理有多种方式,见如下参数;
# This is just like the "Spam Actions" option above, except that it applies
# to messages that are *NOT* spam.
# deliver - deliver the message as normal
# delete - delete the message
# store - store the message in the (non-spam) quarantine
# store-nonmcp - store the message in the non-MCP quarantine
# store-mcp - store the message in the MCP quarantine
# store-nonspam - store the message in the non-spam quarantine
# store-spam - store the message in the spam quarantine
# forward user@domain.com - forward a copy of the message to user@domain.com
# striphtml - convert all in-line HTML content to plain text
# header "name: value" - Add the header
# name: value
# to the message. name must not contain any spaces.
# custom(parameter) - Call the CustomAction function in /usr/lib/Mail-
# Scanner/MailScanner/CustomFunctions/CustomAction
# .pm with the 'parameter' passed in. This can be
# used to implement any custom action you require.
新建一个账户,收集垃圾邮件;
[root@mail postfix]# ssh root@10.6.6.120
mailto:root@10.6.6.120 password:
[root@mail1 ~]# adduser spam -s /sbin/nologin
Changing password for user spam.
New UNIX password:
BAD PASSWORD: it is too short
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
4.开始测试,分别发送一正常与垃圾信给leeki.yan@centos.eb.cn
a.首先从leeki.yan@trinet.com.cn测试一封正常信到leeki.yan@centos.eb.cn,理论上正常信,经过A机器扫描后,会往后面B机器relay,并且寄给leeki.yan@centos.eb.cn,查看日志如下:
Sep 30 16:38:36 mail postfix/smtpd[8637]: connect from unknown[10.0.0.1]
Sep 30 16:38:36 mail postfix/smtpd[8637]: 8002B170301: client=unknown[10.0.0.1]
Sep 30 16:38:36 mail postfix/cleanup[8639]: 8002B170301: hold: header Received: from mail.trinet.com.cn (unknown [10.0.0.1])??by mail.centos.eb.cn (Postfix) with ESMTP id 8002B170301??for <leeki.yan@centos.eb.cn>; Sun, 30 Sep 2007 16:38:36 +0800 (CST) from unknown[10.0.0.1]; from=<leeki.yan@trinet.com.cn> to=<leeki.yan@centos.eb.cn> proto=ESMTP helo=<mail.trinet.com.cn>
Sep 30 16:38:36 mail postfix/cleanup[8639]: 8002B170301: hold: header Received: from triumphweihu ([10.0.0.1]) by mail.trinet.com.cn with Microsoft SMTPSVC(5.0.2195.6713);?? Sun, 30 Sep 2007 16:47:36 +0800 from unknown[10.0.0.1]; from=<leeki.yan@trinet.com.cn> to=<leeki.yan@centos.eb.cn> proto=ESMTP helo=<mail.trinet.com.cn>
Sep 30 16:38:36 mail postfix/cleanup[8639]: 8002B170301: message-id=<00da01c8033d$5e55aa60$de04040a@triumphweihu>
Sep 30 16:38:36 mail postfix/smtpd[8637]: disconnect from unknown[10.0.0.1]
Sep 30 16:38:38 mail MailScanner[8125]: New Batch: Scanning 1 messages, 2650 bytes
Sep 30 16:38:42 mail MailScanner[8125]: Virus and Content Scanning: Starting
Sep 30 16:38:53 mail MailScanner[8125]: Requeue: 8002B170301.BC8D5 to 52652170302
Sep 30 16:38:53 mail MailScanner[8125]: Uninfected: Delivered 1 messages
Sep 30 16:38:53 mail postfix/qmgr[8107]: 52652170302: from=<leeki.yan@trinet.com.cn>, size=2872, nrcpt=1 (queue active)
Sep 30 16:38:53 mail postfix/smtp[8647]: 52652170302: to=<leeki.yan@centos.eb.cn>, relay=10.6.6.120[10.6.6.120], delay=17, status=sent (250 Ok: queued as 122AF2206E0)
Sep 30 16:38:53 mail postfix/qmgr[8107]: 52652170302: removed
见上面红色字体部分,说明已经往后B机器relay成功了!
b.从418027712@qq.com测试一封垃圾信到leeki.yan@centos.eb.cn,理论上垃圾信,经过A机器扫描后,会往后面B机器relay,寄给spam@centos.eb.cn,查看日志如下:
Sep 30 17:05:01 mail postfix/smtpd[3496]: connect from smtpbg12.qq.com[58.60.13.110]
Sep 30 17:05:01 mail postfix/smtpd[3496]: C9D89170301: client=smtpbg12.qq.com[58.60.13.110]
Sep 30 17:05:01 mail postfix/cleanup[3504]: C9D89170301: hold: header Received: from smtpbg12.qq.com (smtpbg12.qq.com [58.60.13.110])??by mail.centos.eb.cn (Postfix) with ESMTP id C9D89170301??for <leeki.yan@centos.eb.cn>; Sun, 30 Sep 2007 17:05:01 +0800 (CST) from smtpbg12.qq.com[58.60.13.110]; from=<418027712@qq.com> to=<leeki.yan@centos.eb.cn> proto=ESMTP helo=<smtpbg12.qq.com>
Sep 30 17:05:01 mail postfix/cleanup[3504]: C9D89170301: message-id=<tencent_46D546001FA9FA1C63F8C299@qq.com>
Sep 30 17:05:01 mail postfix/smtpd[3496]: disconnect from smtpbg12.qq.com[58.60.13.110]
Sep 30 17:05:02 mail MailScanner[3341]: New Batch: Scanning 1 messages, 1614 bytes
Sep 30 17:05:36 mail MailScanner[3341]: Spam Checks: Found 1 spam messages
Sep 30 17:05:36 mail MailScanner[3341]: Virus and Content Scanning: Starting
Sep 30 17:06:20 mail MailScanner[3341]: Requeue: C9D89170301.4D561 to 1B757170304
Sep 30 17:06:20 mail MailScanner[3026]: Uninfected: Delivered 1 messages
Sep 30 17:06:20 mail postfix/qmgr[2587]: 1B757170304: from=<418027712@qq.com>, size=1834, nrcpt=1 (queue active)
Sep 30 17:06:30 mail postfix/smtp[3591]: 1B757170304: to=<spam@centos.eb.cn>, relay=10.6.6.120[10.6.6.120], delay=89, status=sent (250 Ok: queued as 19B222206E0)
Sep 30 17:06:30 mail postfix/qmgr[2587]: 1B757170304: removed
由面日志红色字体部分可以看出,首先检测发现邮件为垃圾邮件,然后,在往B机器relay时,投寄到spam@centos.eb.cn;
5.测试完成!
6.2007年10月8日22时补充说明:
,但是经与jacky网友聊天得知:理论上,邮件网关配置好了后,外部发过的来的邮件到邮件网关时,是不需要查询本地用户组的,他只管往后面丢,所以我测试查找发现,要修改邮件网关的main.cf文件,找到:
#local_recipient_maps =
修改成:
local_recipient_maps =
即把注释给取消掉,就可以!
阅读(1309) | 评论(0) | 转发(0) |
<script type=text/javascript charset=utf-8 src="http://static.bshare.cn/b/buttonLite.js#style=-1&uuid=&pophcol=3&lang=zh"></script> <script type=text/javascript charset=utf-8 src="http://static.bshare.cn/b/bshareC0.js"></script>
http://yanweihu.blog.51cto.com
1。安装centos4.4,安装时只选择一个"开发工具"的包,其它都不勾选,安装完毕;
2。配置yum更新库:
[root@mail]# vi /etc/yum.repos.d/dag.repo
[dag]
name=Dag RPM Repository for Red Hat Enterprise Linux
baseurl=http://apt.sw.be/redhat/el$releasever/en/$basearch/dag
http://mirror.be10.com/centos/$releasever/os/$basearch/
http://centos.hostlink.com.hk/$releasever/os/$basearch/
http://ftp.hostrino.com/pub/centos/
gpgcheck=1
enabled=1
[root@mail]# rpm --import http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt
还有一个导入:(此处暂不导入)
[root@mail]# rpm --import http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-4
3。解决putty连接显示乱码:
vi /etc/sysconfig/i18n将里面内容替换成下面;
LANG="en_US:en"
SUPPORTED="en_US:en:en_US:zh:en_US.en:en_US:en"
SYSFONT="latarcyrheb-sun16"
4。关闭cups(打印服务),
[root@mail log]# /etc/rc.d/init.d/cups stop
Stopping cups: [ OK ]
[root@mail log]# chkconfig cups off
[root@mail log]#
5。解决时间同步问题:
[root@mail ~]# yum install ntp
Dependencies Resolved
=============================================================================
Package Arch Version Repository Size
=============================================================================
Installing:
ntp i386 4.2.0.a.20040617-6.el4 base 1.2 M
Transaction Summary
=============================================================================
Install 1 Package(s)
Update 0 Package(s)
Remove 0 Package(s)
Total download size: 1.2 M
Is this ok [y/N]: y
安装完毕后,就可以有ntpdatae命令了,可以使用ntpdate 命令进行同步了!否则没有ntpdate命令。
[root@mail /]# vi /etc/crontab
将下面:
01 * * * * root run-parts /etc/cron.hourly
02 4 * * * root run-parts /etc/cron.daily
22 4 * * 0 root run-parts /etc/cron.weekly
42 4 1 * * root run-parts /etc/cron.monthly
修改为:
#01 * * * * root run-parts /etc/cron.hourly
#02 4 * * * root run-parts /etc/cron.daily
#22 4 * * 0 root run-parts /etc/cron.weekly
#42 4 1 * * root run-parts /etc/cron.monthly
并添加命令行:意思是每隔三分钟与时钟服务器210.72.145.44同步一次时间
*/3 * * * * root /usr/sbin/ntpdate 210.72.145.44 > /dev/null 2>&1
改完后重启一下服务:
[root@mail /]# service crond restart
Stopping crond: [ OK ]
Starting crond: [ OK ]
[root@mail /]#
6.安装postfix,dovecot,apache,其中蓝色字体,是相依赖的包,绿色为安装的顺序;
查看域名MX记录
[root@mail postfix]# host -t mx centos.eb.cn
centos.eb.cn mail is handled by 10 mail.centos.eb.cn.
[root@mail etc]yum install postfix
[root@mail etc]yum install dovecot
Dependencies Resolved
=============================================================================
Package Arch Version Repository Size
=============================================================================
Installing:
dovecot i386 0.99.11-8.EL4 base 614 k
Installing for dependencies:
mysql i386 4.1.20-2.RHEL4.1 base 2.9 M
perl-DBI i386 1.58-2.el4.rf dag 819 k
perl-Net-Daemon noarch 0.43-1.el4.rf dag 44 k
perl-PlRPC noarch 0.2020-1.el4.rf dag 33 k
postgresql-libs i386 7.4.17-1.RHEL4.1 update 147 k
Transaction Summary
=============================================================================
Install 6 Package(s)
Update 0 Package(s)
Remove 0 Package(s)
Total download size: 4.5 M
Is this ok [y/N]: y
Downloading Packages:
(1/6): postgresql-libs-7. 16% |==== | 24 kB 00:39 ETA
Installing: perl-Net-Daemon ######################### [1/6]
Installing: perl-PlRPC ######################### [2/6]
Installing: perl-DBI ######################### [3/6]
Installing: mysql ######################### [4/6]
Installing: postgresql-libs ######################### [5/6]
Installing: dovecot ######################### [6/6]
[root@mail etc]yum install httpd
=============================================================================
Package Arch Version Repository Size
=============================================================================
Installing:
httpd i386 2.0.52-32.3.ent.centos4 update 888 k
Installing for dependencies:
apr i386 0.9.4-24.5.c4.2 base 88 k
apr-util i386 0.9.4-21 base 51 k
httpd-suexec i386 2.0.52-32.3.ent.centos4 update 29 k
Updating for dependencies:
initscripts i386 7.93.29.EL-1.centos4 base 1.1 M
Transaction Summary
=============================================================================
Install 4 Package(s)
Update 1 Package(s)
Remove 0 Package(s)
Total download size: 2.2 M
Downloading Packages:
(1/5): initscripts-7.93.2 9% |== | 112 kB 03:09 ETA
Running Transaction
Installing: apr ######################### [1/6]
Installing: apr-util ######################### [2/6]
Updating : initscripts ######################### [3/6]
Installing: httpd ######################### [4/6]
Installing: httpd-suexec ######################### [5/6]
Cleanup : initscripts ######################### [6/6]
7。POSTFIX的配置方法:
[root@mail /]# cd /etc/postfix
[root@mail postfix]# cp main.cf main.cf.bak
[root@mail postfix]# vi main.cf修改如下面所示:粉色字为待修改,绿色为修改后)
#myhostname = host.domain.tld
myhostname = mail.centos.eb.cn
#mydomain = domain.tld
mydomain = centos.eb.cn
#myorigin = $mydomain
myorigin = $mydomain
inet_interfaces = localhost
#inet_interfaces = localhost
inet_interfaces = all
mydestination = $myhostname, localhost.$mydomain, localhost
#mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
#mydestination = $myhostname, localhost.$mydomain, localhost
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
#relay_domains = $mydestination
relay_domains = $mydestination
#mynetworks = 168.100.189.0/28, 127.0.0.0/8
mynetworks = 10.0.0.0/8, 127.0.0.0/8
#home_mailbox = Maildir/
home_mailbox = Maildir/
#smtpd_banner = $myhostname ESMTP $mail_name
#smtpd_banner = $myhostname ESMTP $mail_name ($mail_version)
smtpd_banner = $myhostname ESMTP mailserver maintanace by ---Weihu.Yan---
(此段追加在文件结尾)
#append smtp auth config
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain = $myhostname
smtpd_sasl_security_options = noanonymous
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
message_size_limit = 20971520 (表附件大小为20M,20*1024*1024)
配置SMTP认证:
[root@mail postfix]# vi /usr/lib/sasl2/smtpd.conf修改如下:
pwcheck_method: saslauthd
#pwcheck_method: saslauthd
pwcheck_method: auxprop (表示不使用系统用户认证)
[root@mail postfix]# vi /etc/sysconfig/saslauthd
MECH=shadow 找到这一行,在前面加#
#MECH=shadow
FLAGS= 找到此行,在等号后面添加“sasldb”
FLAGS=sasldb 定义认证方式为sasldb2
建立用户邮箱模板:
[root@mail postfix]# mkdir /etc/skel/Maildir
[root@mail postfix]# chmod 700 /etc/skel/Maildir
若已有用户,刚为已存在用户建立邮箱的方法如下:
[root@mail ~]# mkdir /home/leeki.yan/Maildir 为用户(这里以leeki.yan用户为例)建立邮箱目录
[root@mail ~]# chmod 700 /home/leeki.yan/Maildir 设置该用户邮箱目录属性为700
[root@mail ~]# chown leeki.yan. /home/leeki.yan/Maildir 设置该用户邮箱目录为该用户所有
为用户设置SMTP密码:(以root账户为例)
[root@mail postfix]# saslpasswd2 -u mail.centos.eb.cn -c root
Password:
Again (for verification):
[root@mail postfix]#
改变SASL的归属
[root@mail postfix]# chgrp postfix /etc/sasldb2
[root@mail postfix]# chmod 640 /etc/sasldb2
关闭sendmail,及设置不自动启动,并修改默认的MTA
[root@mail postfix]# /etc/rc.d/init.d/sendmail stop
Shutting down sendmail: [ OK ]
Shutting down sm-client: [ OK ]
[root@mail postfix]# chkconfig sendmail off
[root@mail postfix]# chkconfig --list sendmail
sendmail 0:off 1:off 2:off 3:off 4:off 5:off 6:off
[root@mail postfix]# alternatives --config mta
There are 2 programs which provide 'mta'.
Selection Command
-----------------------------------------------
*+ 1 /usr/sbin/sendmail.sendmail
2 /usr/sbin/sendmail.postfix
Enter to keep the current selection[+], or type selection number: 2
[root@mail postfix]#
启动SMTP认证及Postfix服务,并设置相应服务为自启动
[root@mail postfix]# chkconfig saslauthd on
[root@mail postfix]# chkconfig --list saslauthd
saslauthd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@mail postfix]# chkconfig postfix on
[root@mail postfix]# chkconfig --list postfix
postfix 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@mail postfix]# /etc/rc.d/init.d/saslauthd start
Starting saslauthd: [ OK ]
[root@mail postfix]# /etc/rc.d/init.d/postfix start
Starting postfix: [ OK ]
[root@mail postfix]#
查看smtp端口是否为打开
[root@mail postfix]# netstat -tl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 *:809 *:* LISTEN
tcp 0 0 *:sunrpc *:* LISTEN
tcp 0 0 *:ssh *:* LISTEN
tcp 0 0 *:smtp *:* LISTEN
[root@mail postfix]#
8。配置dovecot
[root@mail etc]# vi /etc/dovecot.conf(修改如下面所示:粉色字为待修改,绿色为修改后)
#protocols = imap imaps
protocols = imap imaps pop3 pop3s
#default_mail_env =
default_mail_env = maildir:~/Maildir (定义邮箱的目录)
[root@mail etc]# vi /etc/sysconfig/iptables
添加以下部分:
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 110 -j ACCEPT 为pop3
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 143 -j ACCEPT 为imap
[root@mail etc]# /etc/rc.d/init.d/iptables restart
Flushing firewall rules: [ OK ]
Setting chains to policy ACCEPT: filter [ OK ]
Unloading iptables modules: [ OK ]
Applying iptables firewall rules: [ OK ]
[root@mail etc]#
[root@mail etc]# chkconfig dovecot on
[root@mail etc]# chkconfig --list dovecot
dovecot 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@mail etc]# /etc/rc.d/init.d/dovecot start
Starting Dovecot Imap: [ OK ]
[root@mail etc]#
至此可以测试收发,邮箱服务器的基本功能已实现!
[root@mail etc]# useradd leeki.yan -s /sbin/nologin
[root@mail etc]# passwd leeki.yan
Changing password for user leeki.yan.
New UNIX password:
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
添加用户测试看看吧!
CentOS4.4下邮件服务器架设笔记之SPAM与防毒功能实现
通过上一篇“CentOS4.4下邮件服务器架设笔记之基本功能实现”,至此,我们已经拥有一台可以正常收发MAIL的服务器了,但其功能较少,不具备防毒,防垃圾功效。本篇主要实现添加此功能!且添加了对邮件流量的监控功能!
1.安装clamav防病毒软件;
[root@mail ~]# yum install clamav
Dependencies Resolved
=============================================================================
Package Arch Version Repository Size
=============================================================================
Installing:
clamav i386 0.91.2-1.el4.rf dag 1.1 M
Installing for dependencies:
clamav-db i386 0.91.2-1.el4.rf dag 10 M
Transaction Summary
=============================================================================
Install 2 Package(s)
Update 0 Package(s)
Remove 0 Package(s)
Total download size: 11 M
Is this ok [y/N]: y
Downloading Packages:
Downloading Packages:
(1/2): clamav-0.91.2-1.el 100% |=========================| 1.1 MB 02:31
(2/2): clamav-db-0.91.2-1 100% |=========================| 10 MB 21:27
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing: clamav-db ######################### [1/2]
Installing: clamav ######################### [2/2]
Installed: clamav.i386 0:0.91.2-1.el4.rf
Dependency Installed: clamav-db.i386 0:0.91.2-1.el4.rf
Complete!
上面clamav也可手工下载到:
http://www.baxitek.com/pub/clamav/
wget http://www.baxitek.com/pub/clamav/clamav-db-0.91.2-1.i386.rpm
wget http://www.baxitek.com/pub/clamav/clamav-0.91.2-1.i386.rpm
2.更新杀毒软件病毒定义;
[root@mail ~]# /usr/bin/freshclam
ClamAV update process started at Fri Aug 31 18:55:00 2007
Downloading daily.cvd [100%]
daily.cvd updated (version: 4110, sigs: 16448, f-level: 21, builder: acab)
Database updated (149611 signatures) from db.cn.clamav.net (IP: 58.221.222.69)
WARNING: Clamd was NOT notified: Can't find or parse configuration file /etc/clamd.conf
3.鉴于上面升级病毒码的警告信息:是因为通过yum RPM包方式安装的clamav时,所生成的配置文件,不在/etc目录下,且文件名叫clamav.conf,按下面操作:
[root@mail etc]# find / -name clam*
find: /proc/801/task: No such file or directory
find: /proc/802/task: No such file or directory
find: /proc/803/task: No such file or directory
find: /proc/928/task: No such file or directory
find: /proc/936/task: No such file or directory
/etc/log.d/conf/services/clamav.conf
[root@mail etc]# cp /etc/log.d/conf/services/clamav.conf /etc/clamd.conf
4.安装spamassassin防垃圾软件;
[root@mail ~]# yum -y install spamassassin
Dependencies Resolved
=============================================================================
Package Arch Version Repository Size
=============================================================================
Installing:
spamassassin i386 3.2.3-1.el4.rf dag 1.0 M
Installing for dependencies:
perl-Archive-Tar noarch 1.32-1.el4.rf dag 47 k
perl-Digest-HMAC noarch 1.01-13 base 11 k
perl-Digest-SHA1 i386 2.07-5 base 19 k
perl-IO-Socket-SSL noarch 1.07-2.el4.rf dag 43 k
perl-IO-Zlib noarch 1.05-1.el4.rf dag 15 k
perl-Net-DNS i386 0.61-1.el4.rf dag 271 k
perl-Net-IP noarch 1.25-1.el4.rf dag 30 k
perl-Net-SSLeay i386 1.30-4.el4.centos extras 198 k
perl-Time-HiRes i386 1.55-3 base 22 k
Updating for dependencies:
perl-HTML-Parser i386 3.55-1.el4.rf dag 140 k
Transaction Summary
=============================================================================
Install 10 Package(s)
Update 1 Package(s)
Remove 0 Package(s)
Total download size: 1.8 M
Downloading Packages:
(1/11): perl-HTML-Parser- 100% |=========================| 140 kB 00:24
(2/11): perl-Digest-HMAC- 100% |=========================| 11 kB 00:05
(3/11): perl-Net-DNS-0.61 100% |=========================| 271 kB 00:35
(4/11): perl-Net-SSLeay-1 100% |=========================| 198 kB 00:06
(5/11): perl-Digest-SHA1- 100% |=========================| 19 kB 00:04
(6/11): perl-Net-IP-1.25- 100% |=========================| 30 kB 00:06
(7/11): perl-Time-HiRes-1 100% |=========================| 22 kB 00:04
(8/11): perl-IO-Socket-SS 100% |=========================| 43 kB 00:06
(9/11): perl-Archive-Tar- 100% |=========================| 47 kB 00:07
(10/11): spamassassin-3.2 100% |=========================| 1.0 MB 02:19
(11/11): perl-IO-Zlib-1.0 100% |=========================| 15 kB 00:02
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing: perl-Digest-SHA1 ####################### [ 1/12]
Updating : perl-HTML-Parser ####################### [ 2/12]
Installing: perl-Digest-HMAC ####################### [ 3/12]
Installing: perl-IO-Zlib ####################### [ 4/12]
Installing: perl-Archive-Tar ####################### [ 5/12]
Installing: perl-Time-HiRes ####################### [ 6/12]
Installing: perl-Net-IP ####################### [ 7/12]
Installing: perl-Net-DNS ####################### [ 8/12]
Installing: perl-Net-SSLeay ####################### [ 9/12]
Installing: perl-IO-Socket-SSL ####################### [10/12]
Installing: spamassassin ####################### [11/12]
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LANG = "en_US.en"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LANG = "en_US.en"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
Cleanup : perl-HTML-Parser ####################### [12/12]
Installed: spamassassin.i386 0:3.2.3-1.el4.rf
Dependency Installed: perl-Archive-Tar.noarch 0:1.32-1.el4.rf perl-Digest-HMAC.noarch 0:1.01-13 perl-Digest-SHA1.i386 0:2.07-5 perl-IO-Socket-SSL.noarch 0:1.07-2.el4.rf perl-IO-Zlib.noarch 0:1.05-1.el4.rf perl-Net-DNS.i386 0:0.61-1.el4.rf perl-Net-IP.noarch 0:1.25-1.el4.rf perl-Net-SSLeay.i386 0:1.30-4.el4.centos perl-Time-HiRes.i386 0:1.55-3
Dependency Updated: perl-HTML-Parser.i386 0:3.55-1.el4.rf
Complete!
[root@mail ~]#
5.针对上面红色字体的告警信息,我们修改一下/etc/sysconfig/i18n文件,如果不修改在安装MailScanner时候,每次重新启动都提示,但是暂不知道有没有什么其它的影响!
[root@mail ~]# vi /etc/sysconfig/i18n
添加以下命令行:
LC_ALL="C"
并将:LANG="en_US.UTF-8"
改为:LANG="en_US"
6.接下来我们安装MailScanner,首先我们要下载,可以到官方网上下,地址:http://www.mailscanner.info/上下载。
[root@mail tmp]# wget http://www.mailscanner.info/files/4/rpm/MailScanner-4.62.9-3.rpm.tar.gz
--16:40:51-- http://www.mailscanner.info/files/4/rpm/MailScanner-4.62.9-3.rpm.tar.gz
=> `MailScanner-4.62.9-3.rpm.tar.gz'
Resolving http://www.mailscanner.info/... 81.17.252.15
Connecting to http://www.mailscanner.info/|81.17.252.15|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 4,239,584 (4.0M) [application/x-gzip]
100%[====================================>] 4,239,584 6.74K/s ETA 00:00
16:50:54 (6.88 KB/s) - `MailScanner-4.62.9-3.rpm.tar.gz' saved [4239584/4239584]
[root@mail tmp]# tar zxvf MailScanner-4.62.9-3.rpm.tar.gz #解压缩此包
[root@mail tmp]# cd MailScanner-4.62.9-3
[root@mail MailScanner-4.62.9-3]# ./install.sh #此过程较长,此时可以喝一杯去,哈哈!
Good. You have the patch command.
Good, you have /usr/src/redhat in place.
Writing a .rpmmacros file in your home directory to stop
unpackaged files breaking the build process.
You can delete it once MailScanner is installed if you want to.
Now to install MailScanner itself.
NOTE: If you get lots of errors here, run the install.sh script
NOTE: again with the command "./install.sh nodeps"
Preparing... ########################################### [100%]
1:mailscanner ########################################### [100%]
Good, SpamAssassin site rules found in /etc/mail/spamassassin
To activate MailScanner run the following commands:
service sendmail stop
chkconfig sendmail off
chkconfig --level 2345 MailScanner on
service MailScanner start
For technical support, please read the MAQ at www.mailscanner.biz/maq/
and buy the book at www.mailscanner.info/store
----------------------------------------------------------
Please buy the MailScanner book from http://www.mailscanner.info/!
It is a very useful administration guide and introduction
to MailScanner. All the proceeds go directly to making
MailScanner a better supported package than it is today.
7.配置MainScanner及设置POSTFIX使用MailScanner调用clamav及SA;(红色字为待修改,绿色为修改后的内容.
[root@mail MailScanner-4.62.9-3]# vi /etc/MailScanner/MailScanner.conf
%org-name% = yoursite
%org-name% = centosmail
%org-long-name% = Your Organisation Name Here
%org-long-name% = CentosMail_Leeki.Yan
%web-site% = http://www.your-organisation.com/
%web-site% = http://www.centos.eb.cn/
Run As User =
Run As User = postfix
Run As Group =
Run As Group = postfix
Incoming Queue Dir = /var/spool/mqueue.in
Incoming Queue Dir = /var/spool/postfix/hold
Outgoing Queue Dir = /var/spool/mqueue
Outgoing Queue Dir = /var/spool/postfix/incoming
MTA = sendmail
MTA = postfix
Virus Scanners = auto
Virus Scanners = clamav
Always Include SpamAssassin Report = no
Always Include SpamAssassin Report = yes
SpamAssassin User State Dir =
SpamAssassin User State Dir = /var/spool/MailScanner/spamassassin
Incoming Work User =
Incoming Work Group =
Incoming Work User = postfix
Incoming Work Group = postfix
SpamAssassin Install Prefix =
SpamAssassin Install Prefix = /usr/bin
Quarantine User =
Quarantine Group =
Quarantine User = postfix
Quarantine Group = postfix
[root@mail MailScanner-4.62.9-3]# vi /etc/MailScanner/MailScanner.conf
[root@mail MailScanner-4.62.9-3]# cd /var/spool/MailScanner/
[root@mail MailScanner]# ls -al
total 20
drwxr-xr-x 4 root root 4096 Aug 31 20:34 .
drwxr-xr-x 16 root root 4096 Aug 31 20:34 ..
drwxr-xr-x 8 root root 4096 Aug 31 21:01 incoming
drwxr-xr-x 2 root root 4096 Aug 31 20:34 quarantine
[root@mail MailScanner]# mkdir spamassassin
[root@mail MailScanner]# mkdir .spamassassin
[root@mail MailScanner]# chown -R postfix:postfix /var/spool/MailScanner/*
[root@mail MailScanner]# ls -al
total 28
drwxr-xr-x 6 root root 4096 Aug 31 21:48 .
drwxr-xr-x 16 root root 4096 Aug 31 20:34 ..
drwxr-xr-x 2 root root 4096 Aug 31 21:48 .spamassassin
drwxr-xr-x 8 postfix postfix 4096 Aug 31 21:01 incoming
drwxr-xr-x 2 postfix postfix 4096 Aug 31 20:34 quarantine
drwxr-xr-x 2 postfix postfix 4096 Aug 31 21:48 spamassassin
修改main.cf文件,让其使用MainScanner;
[root@mail MailScanner]# vi /etc/postfix/main.cf
将: #header_checks = regexp:/etc/postfix/header_checks
改为:header_checks = regexp:/etc/postfix/header_checks
[root@mail MailScanner]# mv /etc/postfix/header_checks /etc/postfix/header_checks.bak
[root@mail MailScanner]# vi /etc/postfix/header_checks
增加如下命令:
(注意,空格处要使用 tab 键,添加如下内容)
/^Received:/ HOLD
[root@mail MailScanner]# chkconfig spamassassin on
[root@mail MailScanner]# service spamassassin start
Starting spamd: [ OK ]
[root@mail MailScanner]#
[root@mail MailScanner]# chkconfig postfix off #关闭postfix自启动,因MailScanner启动时,自动启动postfix
[root@mail MailScanner]# chkconfig MailScanner on
[root@mail MailScanner]# /etc/rc.d/init.d/MailScanner start
Starting MailScanner daemons:
incoming postfix: [ OK ]
outgoing postfix: [ OK ]
MailScanner: [ OK ]
查看clamav有没有启动,使用下面命令:
[root@mail MailScanner]# ps -aux | grep clamd
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.3/FAQ
root 12603 0.0 0.2 2992 444 pts/0 S+ 22:08 0:00 grep clamd
8.重新启动一下机器,开始测试吧!
[root@mail~]#tail -f /var/log/maillog
开始测试发一封邮件,可以在日志中查到到以下内容:
Aug 31 22:23:18 mail MailScanner[2600]: Using locktype = flock
Aug 31 22:23:18 mail MailScanner[3338]: Using SpamAssassin results cache
Aug 31 22:23:18 mail MailScanner[3338]: Connected to SpamAssassin cache database
Aug 31 22:23:18 mail MailScanner[3338]: Enabling SpamAssassin auto-whitelist functionality...
Aug 31 22:23:33 mail MailScanner[2709]: Using locktype = flock
Aug 31 22:23:36 mail MailScanner[3264]: Using locktype = flock
Aug 31 22:23:38 mail MailScanner[3336]: Using locktype = flock
Aug 31 22:23:39 mail MailScanner[3338]: Using locktype = flock
Aug 31 22:24:13 mail pop3-login: Login: leeki.yan [::ffff:10.0.0.25]
Aug 31 22:25:39 mail postfix/smtpd[3345]: connect from unknown[10.0.0.25]
Aug 31 22:25:39 mail postfix/smtpd[3345]: C38C71702CA: client=unknown[10.0.0.25]
Aug 31 22:25:40 mail postfix/cleanup[3348]: C38C71702CA: hold: header Received: from ts (unknown [10.0.0.25])??by mail.centos.eb.cn (Postfix) with SMTP id C38C71702CA??for <leeki.yan@centos.eb.cn>; Fri, 31 Aug 2007 22:25:39 +0800 (CST) from unknown[10.0.0.25]; from=<leeki.yan@centos.eb.cn> to=<leeki.yan@centos.eb.cn> proto=SMTP helo=<ts>
Aug 31 22:25:40 mail postfix/cleanup[3348]: C38C71702CA: message-id=<001901c7ebdb$f70f9ff0$1900000a@triumph>
Aug 31 22:25:40 mail postfix/smtpd[3345]: disconnect from unknown[10.0.0.25]
Aug 31 22:25:43 mail MailScanner[3264]: New Batch: Scanning 1 messages, 934 bytes
Aug 31 22:25:59 mail pop3-login: Login: leeki.yan [::ffff:10.0.0.25]
Aug 31 22:25:59 mail MailScanner[3264]: Virus and Content Scanning: Starting
Aug 31 22:26:14 mail MailScanner[3264]: Requeue: C38C71702CA.8937F to 14A741702E8
Aug 31 22:26:14 mail MailScanner[3264]: Uninfected: Delivered 1 messages
Aug 31 22:26:14 mail postfix/qmgr[2579]: 14A741702E8: from=<leeki.yan@centos.eb.cn>, size=1212, nrcpt=1 (queue active)
Aug 31 22:26:14 mail postfix/local[3361]: 14A741702E8: to=<leeki.yan@centos.eb.cn>, relay=local, delay=35, status=sent (delivered to maildir)
Aug 31 22:26:14 mail postfix/qmgr[2579]: 14A741702E8: removed
Aug 31 22:28:29 mail pop3-login: Login: leeki.yan [::ffff:10.0.0.25]
从上面的日志可以看出,MailScanner已经开始起作用了!
9.另MailScanner.conf配置文件其它参数说明:
a.用mailscanner发信自动带加上这个内容:
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean
取消这种设置方法:vi /etc/MailScanner/MailScaner.conf
Sign Clean Messages = yes
改成
Sign Clean Messages = no
b.可以从网上找个翻译过的report中文文件,以后当发生警告时,就会发中文的告警信息;
mv cn /etc/MailScanner/reports即可
/etc/MailScanner/reports/en
因为部分中文没有,所有LOG里有报错:
方法:
cd /etc/MailScanner/reports/cn
cp ../en/* ../cn
当提示覆盖时,选n即可!
c.设置本地域不进行扫描:
编辑/etc/MailScanner/MailScanner.conf文件,
修改 Is Definitely Not Spam = /etc/MailScanner/rules/spam.whitelist.rules
vi /etc/MailScanner/rules/spam.whitelist.rules
加入 From: *@centos.eb.cn yes #centos.eb.cn是本地域名
重启MailScannerl。
在/etc/mail/spamassassin/local.cf里面加了一句whitelist_from *@trinet.com.cn
这样发出去的邮件都不会被标记为 spam ,但是还是经过了检查的,我想在问下,这两种设置的区别在那里 ?
答:设置whitelist_from,实际上还是会进行spam检查,whitelist_from 是表示在分数方面 -100分
而设置spam.whitelist.rules是直接标记不是垃圾邮件,不再进行spam检查的。
d.
Max Children = 5 #
这是设置 MailScanner 的进程数,如果你的计算机不够强劲的话,建议你将数值设小点,因为 MailScanner 比较耗资
源,尤其是内存
e.Virus Scanner Timeout = 30 # 病毒查杀软件扫描你的邮件的最长时间
f.Find Phishing Fraud = yes # 是否开启防钓鱼邮件检测功能
g.
Filename Rules = %etc-dir%/filename.rules.conf
Filetype Rules = %etc-dir%/filetype.rules.conf # 这两个参数用来设置你的邮件系统能接收或发送何种名称的附件
h.
Max SpamAssassin Size = 1024k # 设置 spamassassin 只能扫描最大为多少的邮件
i:
Syslog Facility = mail
Log Speed = no
Log Spam = no
Log Non Spam = no
Log Permitted Filenames = no
Log Permitted Filetypes = no
Log Silent Viruses = no
Log Dangerous HTML Tags = no # 上面这些参数是设置 MailScanner 是否在 maillog 日志中记录相关的信息。如果你的计算机不够强劲的 话,建议你还是选 no 吧。
10.安装mailscanner-mrtg监控邮件的流量;
[root@mail tmp]# wget http://nchc.dl.sourceforge.net/sourceforge/mailscannermrtg/mailscanner-mrtg-0.10.00-1.noarch.rpm
[root@mail tmp]# rpm -ivh mailscanner-mrtg-0.10.00-1.noarch.rpm
warning: mailscanner-mrtg-0.10.00-1.noarch.rpm: V3 DSA signature: NOKEY, key ID e342f442
error: Failed dependencies:
mrtg >= 2.9 is needed by mailscanner-mrtg-0.10.00-1.noarch
Suggested resolutions:
/home/buildcentos/CENTOS/en/4.0/i386/CentOS/RPMS/mrtg-2.10.15-1.i386.rpm
出现上面的报错,这是包依赖的原因,接下来先安装mrtg,再安装mailscanner-mrtg
[root@mail tmp]# yum -y install mrtg
Dependencies Resolved
=============================================================================
Package Arch Version Repository Size
=============================================================================
Installing:
mrtg i386 2.10.15-1 base 914 k
Installing for dependencies:
gd i386 2.0.28-5.4E base 119 k
Transaction Summary
=============================================================================
Install 2 Package(s)
Update 0 Package(s)
Remove 0 Package(s)
Total download size: 1.0 M
Downloading Packages:
(1/2): gd-2.0.28-5.4E.i38 100% |=========================| 119 kB 02:48
(2/2): mrtg-2.10.15-1.i38 100% |=========================| 914 kB 13:02
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing: gd ######################### [1/2]
Installing: mrtg ######################### [2/2]
Installed: mrtg.i386 0:2.10.15-1
Dependency Installed: gd.i386 0:2.0.28-5.4E
Complete!
再次安装mailscanner-mrtg,发现可以安装了,见下面:
[root@mail tmp]# rpm -ivh mailscanner-mrtg-0.10.00-1.noarch.rpm
warning: mailscanner-mrtg-0.10.00-1.noarch.rpm: V3 DSA signature: NOKEY, key ID e342f442
Preparing... ########################################### [100%]
1:mailscanner-mrtg ########################################### [100%]
Running MRTG to get your initial graphs (Could be slow)
Stopping httpd: [FAILED]
Starting httpd: httpd: Could not determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
[ OK ]
备注:在安装好mailscanner-mrtg后,发现maillog里面总报如下错误;
Oct 25 15:20:02 mailgate MailScanner-MRTG[5072]: ERROR: Snmpwalk Binary
specified in /etc/MailScanner/mailscanner-mrtg.conf is not executable
or not present. Maybe you need to install the snmp or snmp-utils
packages. See the README.SNMP file in the docs. - Skipping snmp
functions
Oct 25 15:20:02 mailgate MailScanner-MRTG[5072]: Unable to find a
mountpoint for /var/spool. Please set Spool Directory in mailscanner-
mrtg.conf to a valid mountpoint. You can see a list of mointpoints on
your system by using the df command.
Oct 25 15:20:02 mailgate MailScanner-MRTG[5072]: Unable to find a
mountpoint for /var/spool/MailScanner/incoming. Please set MailScanner
Work Directory in mailscanner-mrtg.conf to a valid mountpoint. You can
see a list of mointpoints on your system by using the df command
侦对上面的错误:(因为没有安装snmp包,所以CPU,MEM等图标就为空了)
vi /etc/Mailscanner/mailscanner-mrtg.conf
将
Use SNMP = yes
Snmpwalk Binary = /usr/bin/snmpwalk
MailScanner Work Directory = /var/spool/MailScanner/incoming
Spool Directory = /var/spool
修改为:
#Use SNMP = yes
#Snmpwalk Binary = /usr/bin/snmpwalk
MailScanner Work Directory = /
Spool Directory = /
11.配置apache自启动及mailscanner-mrtg参数修改(上一篇文章已经安装了apache)
[root@mail tmp]#chkconfig httpd on
[root@mail tmp]# vi /etc/MailScanner/mailscanner-mrtg.conf
MTA = sendmail
MTA = postfix
Incoming Queue Dir = /var/spool/mqueue.in/ # Sendmail
Incoming Queue Dir = /var/spool/postfix/hold/ # Postfix
Outgoing Queue Dir = /var/spool/mqueue/ # Sendmail
Outgoing Queue Dir = /var/spool/postfix/incoming/ # Sendmail
Interfaces to Monitor = eth0(此参数视情况而定修改,使用ifconfig -a查看后,再作决定)
例如本机就无需修改!见下面:蓝色字体
[root@mail tmp]# ifconfig -a
eth0 Link encap:Ethernet HWaddr 00:C0:A8:F5:06:CD
inet addr:10.6.6.111 Bcast:10.255.255.255 Mask:255.0.0.0
inet6 addr: fe80::2c0:a8ff:fef5:6cd/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:5950 errors:0 dropped:0 overruns:0 frame:0
TX packets:3547 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1585146 (1.5 MiB) TX bytes:463239 (452.3 KiB)
重新启动一下apache服务,然后在浏览器中输入http://邮件服务器的IP地址/mailscanner-mrtg/就可以看到流量图了!
12.其它的设定;
a.病毒库自动更新设定:
[root@mail tmp]# vi /etc/freshclam.conf
增加:LogFileMaxSize 2M
将#PidFile /var/run/freshclam.pid
改为:PidFile /var/run/freshclam.pid
[root@mail tmp]# crontab -e
0 */12 * * * /usr/bin/freshclam --quiet -l /var/log/clamav/freshclam.log 表每各12小时更新一次
b.设置spamassassin,支持CCERT中文垃圾邮件过滤规则集及自动更新
[root@mail tmp]# wget -N -P /usr/share/spamassassin www.ccert.edu.cn/spam/sa/Chinese_rules.cf
[root@mail tmp]# crontab -e
把下面一行复制到里面,进行自动更新规则
0 0 1 * * wget -N -P /usr/share/spamassassin www.ccert.edu.cn/spam/sa/Chinese_rules.cf; /etc/rc.d/init.d/spamassassin restart
# sa-learn --sync -D -p user_prefs (建立学习系统)
#sa-learn --dump all(查看自学习的数据信息)
13.至此防毒防垃圾功能都已实现,别特别注意一点:
MailScanner.conf中其中有一个参数
原始值:SpamAssassin Local Rules Dir =
此参数网上很多参考的文档设定为:
SpamAssassin Local Rules Dir =/etc/MailScanner
本人暂不推荐设定此参数,因为我在安装的时候发现,按照网上相关网关设定的后,邮件全部卡在队列里,日志里总重报如下信息,却没有报错信息,郁闷啊!
Aug 25 22:58:27 mail MailScanner[5619]: Using SpamAssassin results cache
Aug 25 22:58:27 mail MailScanner[5619]: Connected to SpamAssassin cache database
Aug 25 22:58:27 mail MailScanner[5619]: Enabling SpamAssassin auto-whitelist functionality...
Aug 25 22:58:30 mail MailScanner[5620]: MailScanner E-Mail Virus Scanner version 4.62.9 starting...
Aug 25 22:58:30 mail MailScanner[5620]: Read 794 hostnames from the phishing whitelist
Aug 25 22:58:30 mail MailScanner[5620]: SpamAssassin temporary working directory is /var/spool/MailScanner/incoming/SpamAssassin-Temp
Aug 25 22:58:32 mail MailScanner[5620]: Using SpamAssassin results cache
Aug 25 22:58:32 mail MailScanner[5620]: Connected to SpamAssassin cache database
Aug 25 22:58:32 mail MailScanner[5620]: Enabling SpamAssassin auto-whitelist functionality...
Aug 25 22:58:35 mail MailScanner[5626]: MailScanner E-Mail Virus Scanner version 4.62.9 starting...
Aug 25 22:58:35 mail MailScanner[5626]: Read 794 hostnames from the phishing whitelist
Aug 25 22:58:36 mail MailScanner[5626]: SpamAssassin temporary working directory is /var/spool/MailScanner/incoming/SpamAssassin-Temp
查看队列发现:无论是发信还是收信,邮件全部卡在队列里:测试发和收,都会被卡在队列里
[root@mail incoming]# mailq
-Queue ID- --Size-- ----Arrival Time---- -Sender/Recipient-------
695912341DA! 5535 Sat Aug 25 22:55:59 root@centos.eb.cn
root@centos.eb.cn
07D6B2341D8! 11042 Sat Aug 25 22:34:34 leeki.yan@centos.eb.cn
leeki.yan@centos.eb.cn
BEEBD2341D9! 2085 Sat Aug 25 23:00:58 leeki.yan@centos.eb.cn
leeki.yan@centos.eb.cn
-- 18 Kbytes in 3 Requests.
为此花掉三个日日夜夜排错!别提多惨啦!至此所需防毒防垃圾及流量监控都已实现!其它相关高级设定及优化,待总结。。。。
CentOS4.4下邮件服务器架设笔记之邮件网关功能实现
1.通过参考以上两篇文章:
CentOS4.4下邮件服务器架设笔记之基本功能实现
CentOS4.4下邮件服务器架设笔记之SPAM防毒功能实现
我们基本上实现了邮件收发,以及对垃圾邮件过滤的功能,但是目前面对企业来说,用microsoft exchange的比较多,我的想法,就是想要把这台邮件服务器的变成邮件网关,所有流进内部邮件服务器的邮件先经过MX GATEWAY扫描后,再往后面丢;虽然目前市面上很多这样功能的产品,但是价格却是一笔投资,但是LINUX却能容易做到;我在此写BLOG,把自己测试的情况与大家交流,相信对初学者是一个总结;
包括此篇文章的总结,也是花费我了将近一个月的时间抽空测试总结出来的,我希望以此作为抛砖引玉的功能,让大家把自己更好的总结给贡献出来!我自己是一个LINUX初学者,我想通过此平台认识更多的朋友,大家互相交流一下! QQ:418027712
2.转入正题:
首先介绍下我的内网测试环境:
a.参考上面两篇文档:分别架设服务器A,其IP地址:10.6.6.111;
b.新安装一台邮件服务器B,只包含(postfix+dovecot),没有垃圾过滤功能;来替代现实环境的exchange服务器,因为安装linux邮件服务器比microsoft平台的exchange快,简单,更重要的,找个古董机器都能装;
c.两台机器都是同一个域,centos.eb.cn
A机器名:mail.centos.eb.cn B机器名:mail1.cenots.eb.cn
http://blog.51cto.com/attachment/200709/200709301191138323937.jpg" border="0" />
3.开始配置:
a.配置邮件网关机器A,修改通过传输表实现转发;
即当邮件发给A机器时,A全部转发给B机器;
[root@mail ~]# cd /etc/postfix
[root@mail postfix]# vi main.cf
增加
transport_maps = hash:/etc/postfix/transport
然后保存退出,并编辑:
[root@mail postfix]# vi transport
增加
centos.eb.cn relay:[10.6.6.120]
保存退出后,执行:
[root@mail postfix]# postmap /etc/postfix/transport
[root@mail postfix]# postfix reload
postfix/postfix-script: refreshing the Postfix mail system
b.配置MailScanner.conf实现,当A机器对收到的外部邮件判断垃圾邮件时,丢到B机器的指定帐户spam@centos.eb.cn;
[root@mail postfix]# vi /etc/MailScanner/MailScanner.conf
#Spam Actions = deliver header "X-Spam-Status: Yes" #将此行的配置注释掉;
Spam Actions = forward spam@centos.eb.cn #转发指定账户配置
#High Scoring Spam Actions = deliver header "X-Spam-Status: Yes" #将此行的配置注释掉;
High Scoring Spam Actions = forward spam@centos.eb.cn #转发指定账户配置
重新启动一下MailScanner
[root@mail postfix]# service MailScanner restart
Shutting down MailScanner daemons:
MailScanner: [ OK ]
incoming postfix: [ OK ]
outgoing postfix: [ OK ]
Waiting for MailScanner to die gracefully ....................................................................... dead.
Starting MailScanner daemons:
incoming postfix: [ OK ]
outgoing postfix: [ OK ]
MailScanner: [ OK ]
[root@mail postfix]#
其实MailScanner在判定为垃圾邮件处理有多种方式,见如下参数;
# This is just like the "Spam Actions" option above, except that it applies
# to messages that are *NOT* spam.
# deliver - deliver the message as normal
# delete - delete the message
# store - store the message in the (non-spam) quarantine
# store-nonmcp - store the message in the non-MCP quarantine
# store-mcp - store the message in the MCP quarantine
# store-nonspam - store the message in the non-spam quarantine
# store-spam - store the message in the spam quarantine
# forward user@domain.com - forward a copy of the message to user@domain.com
# striphtml - convert all in-line HTML content to plain text
# header "name: value" - Add the header
# name: value
# to the message. name must not contain any spaces.
# custom(parameter) - Call the CustomAction function in /usr/lib/Mail-
# Scanner/MailScanner/CustomFunctions/CustomAction
# .pm with the 'parameter' passed in. This can be
# used to implement any custom action you require.
新建一个账户,收集垃圾邮件;
[root@mail postfix]# ssh root@10.6.6.120
mailto:root@10.6.6.120 password:
[root@mail1 ~]# adduser spam -s /sbin/nologin
Changing password for user spam.
New UNIX password:
BAD PASSWORD: it is too short
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
4.开始测试,分别发送一正常与垃圾信给leeki.yan@centos.eb.cn
a.首先从leeki.yan@trinet.com.cn测试一封正常信到leeki.yan@centos.eb.cn,理论上正常信,经过A机器扫描后,会往后面B机器relay,并且寄给leeki.yan@centos.eb.cn,查看日志如下:
Sep 30 16:38:36 mail postfix/smtpd[8637]: connect from unknown[10.0.0.1]
Sep 30 16:38:36 mail postfix/smtpd[8637]: 8002B170301: client=unknown[10.0.0.1]
Sep 30 16:38:36 mail postfix/cleanup[8639]: 8002B170301: hold: header Received: from mail.trinet.com.cn (unknown [10.0.0.1])??by mail.centos.eb.cn (Postfix) with ESMTP id 8002B170301??for <leeki.yan@centos.eb.cn>; Sun, 30 Sep 2007 16:38:36 +0800 (CST) from unknown[10.0.0.1]; from=<leeki.yan@trinet.com.cn> to=<leeki.yan@centos.eb.cn> proto=ESMTP helo=<mail.trinet.com.cn>
Sep 30 16:38:36 mail postfix/cleanup[8639]: 8002B170301: hold: header Received: from triumphweihu ([10.0.0.1]) by mail.trinet.com.cn with Microsoft SMTPSVC(5.0.2195.6713);?? Sun, 30 Sep 2007 16:47:36 +0800 from unknown[10.0.0.1]; from=<leeki.yan@trinet.com.cn> to=<leeki.yan@centos.eb.cn> proto=ESMTP helo=<mail.trinet.com.cn>
Sep 30 16:38:36 mail postfix/cleanup[8639]: 8002B170301: message-id=<00da01c8033d$5e55aa60$de04040a@triumphweihu>
Sep 30 16:38:36 mail postfix/smtpd[8637]: disconnect from unknown[10.0.0.1]
Sep 30 16:38:38 mail MailScanner[8125]: New Batch: Scanning 1 messages, 2650 bytes
Sep 30 16:38:42 mail MailScanner[8125]: Virus and Content Scanning: Starting
Sep 30 16:38:53 mail MailScanner[8125]: Requeue: 8002B170301.BC8D5 to 52652170302
Sep 30 16:38:53 mail MailScanner[8125]: Uninfected: Delivered 1 messages
Sep 30 16:38:53 mail postfix/qmgr[8107]: 52652170302: from=<leeki.yan@trinet.com.cn>, size=2872, nrcpt=1 (queue active)
Sep 30 16:38:53 mail postfix/smtp[8647]: 52652170302: to=<leeki.yan@centos.eb.cn>, relay=10.6.6.120[10.6.6.120], delay=17, status=sent (250 Ok: queued as 122AF2206E0)
Sep 30 16:38:53 mail postfix/qmgr[8107]: 52652170302: removed
见上面红色字体部分,说明已经往后B机器relay成功了!
b.从418027712@qq.com测试一封垃圾信到leeki.yan@centos.eb.cn,理论上垃圾信,经过A机器扫描后,会往后面B机器relay,寄给spam@centos.eb.cn,查看日志如下:
Sep 30 17:05:01 mail postfix/smtpd[3496]: connect from smtpbg12.qq.com[58.60.13.110]
Sep 30 17:05:01 mail postfix/smtpd[3496]: C9D89170301: client=smtpbg12.qq.com[58.60.13.110]
Sep 30 17:05:01 mail postfix/cleanup[3504]: C9D89170301: hold: header Received: from smtpbg12.qq.com (smtpbg12.qq.com [58.60.13.110])??by mail.centos.eb.cn (Postfix) with ESMTP id C9D89170301??for <leeki.yan@centos.eb.cn>; Sun, 30 Sep 2007 17:05:01 +0800 (CST) from smtpbg12.qq.com[58.60.13.110]; from=<418027712@qq.com> to=<leeki.yan@centos.eb.cn> proto=ESMTP helo=<smtpbg12.qq.com>
Sep 30 17:05:01 mail postfix/cleanup[3504]: C9D89170301: message-id=<tencent_46D546001FA9FA1C63F8C299@qq.com>
Sep 30 17:05:01 mail postfix/smtpd[3496]: disconnect from smtpbg12.qq.com[58.60.13.110]
Sep 30 17:05:02 mail MailScanner[3341]: New Batch: Scanning 1 messages, 1614 bytes
Sep 30 17:05:36 mail MailScanner[3341]: Spam Checks: Found 1 spam messages
Sep 30 17:05:36 mail MailScanner[3341]: Virus and Content Scanning: Starting
Sep 30 17:06:20 mail MailScanner[3341]: Requeue: C9D89170301.4D561 to 1B757170304
Sep 30 17:06:20 mail MailScanner[3026]: Uninfected: Delivered 1 messages
Sep 30 17:06:20 mail postfix/qmgr[2587]: 1B757170304: from=<418027712@qq.com>, size=1834, nrcpt=1 (queue active)
Sep 30 17:06:30 mail postfix/smtp[3591]: 1B757170304: to=<spam@centos.eb.cn>, relay=10.6.6.120[10.6.6.120], delay=89, status=sent (250 Ok: queued as 19B222206E0)
Sep 30 17:06:30 mail postfix/qmgr[2587]: 1B757170304: removed
由面日志红色字体部分可以看出,首先检测发现邮件为垃圾邮件,然后,在往B机器relay时,投寄到spam@centos.eb.cn;
5.测试完成!
6.2007年10月8日22时补充说明:
,但是经与jacky网友聊天得知:理论上,邮件网关配置好了后,外部发过的来的邮件到邮件网关时,是不需要查询本地用户组的,他只管往后面丢,所以我测试查找发现,要修改邮件网关的main.cf文件,找到:
#local_recipient_maps =
修改成:
local_recipient_maps =
即把注释给取消掉,就可以!
相关热门文章
给主人留下些什么吧!~~
评论热议