服务器维护,服务器代维,安全设置,漏洞扫描,入侵检测服务

运维之家

 找回密码
 注册
搜索
查看: 10109|回复: 1

postfix+dovecot+sasl2+虚拟域名+sasl邮件加密

[复制链接]
dirtysea 发表于 2010-5-6 17:21:13 | 显示全部楼层 |阅读模式
安装Postfix

  然后,安装Postfix。

[root@sample ~]# yum -y install postfix  ← 在线安装Postfix

Setting up Install Process
Setting up repositories
dag 100% |=========================| 1.1 kB 00:00
update 100% |=========================| 951 B 00:00
base 100% |=========================| 1.1 kB 00:00
addons 100% |=========================| 951 B 00:00
extras 100% |=========================| 1.1 kB 00:00
Reading repository metadata in from local files
primary.xml.gz 100% |=========================| 28 kB 00:04
update : ################################################## 84/84
Added 84 new packages, deleted 1499 old in 3.44 seconds
primary.xml.gz 100% |=========================| 157 B 00:00
Added 0 new packages, deleted 1499 old in 1.97 seconds
primary.xml.gz 100% |=========================| 26 kB 00:00
extras : ################################################## 102/102
Added 102 new packages, deleted 1499 old in 2.73 seconds
Reducing Dag RPM Repository for Red Hat Enterprise Linux to included packages only
Finished
Parsing package install arguments
Resolving Dependencies
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for postfix to pack into transaction set.
postfix-2.2.10-1.RHEL4.2. 100% |=========================| 40 kB 00:00
---> Package postfix.i386 2:2.2.10-1.RHEL4.2 set to be updated
--> Running transaction check Dependencies Resolved
=============================================================================
Package Arch Version Repository Size
=============================================================================
Installing:
postfix i386 2:2.2.10-1.RHEL4.2 base 3.0 M
Transaction Summary
=============================================================================
Install 1 Package(s)
Update 0 Package(s)
Remove 0 Package(s)
Total download size: 3.0 M
Downloading Packages:
(1/1): postfix-2.2.10-1.R 100% |=========================| 3.0 MB 00:05
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing: postfix ######################### [1/1]
Installed: postfix.i386 2:2.2.10-1.RHEL4.2
Complete!

配置Postfix及相关组件

[1] 对Postfix进行配置。

[root@sample ~]# vi /etc/postfix/main.cf  ← 编辑Postfix的配置文件

#myhostname = host.domain.tld  ← 找到此行,将等号后面的部分改写为主机名
 ↓
myhostname = sample.centospub.com  ← 变为此状态,设置系统的主机名

#mydomain = domain.tld  ← 找到此行,将等号后面的部分改写为域名
 ↓
mydomain = centospub.com  ← 变为此状态,设置域名(我们将让此处设置将成为E-mail地址“@”后面的部分)

#myorigin = $mydomain  ← 找到此行,将行首的#去掉
 ↓
myorigin = $mydomain  ← 变为此状态,将发信地址“@”后面的部分设置为域名(非系统主机名)

inet_interfaces = localhost  ← 找到此行,将“localhost”改为“all”
 ↓
inet_interfaces = all  ← 变为此状态,接受来自所有网络的请求

mydestination = $myhostname, localhost.$mydomain, localhost  ← 找到此行,在行为添加“$mydomain”
 ↓
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain  ← 变为此状态,指定发给本地邮件的域名

#relay_domains = $mydestination  ← 找到此行,将行首的#去掉
 ↓
relay_domains = $mydestination  ← 变为此状态,定义允许转发的域名

#mynetworks = 168.100.189.0/28, 127.0.0.0/8  ← 找到此行,依照自己的内网情况修改
 ↓
mynetworks = 168.100.189.0/28, 127.0.0.0/8  ← 变为此状态,指定内网和本地的IP地址范围

#home_mailbox = Maildir/  ← 找到这一行,去掉行首的#
 ↓
home_mailbox = Maildir/  ← 变为此状态,指定用户邮箱目录

# SHOW SOFTWARE VERSION OR NOT
#
# The smtpd_banner parameter specifies the text that follows the 220
# code in the SMTP server's greeting banner. Some people like to see
# the mail version advertised. By default, Postfix shows no version.
#
# You MUST specify $myhostname at the start of the text. That is an
# RFC requirement. Postfix itself does not care.
#
#smtpd_banner = $myhostname ESMTP $mail_name
#smtpd_banner = $myhostname ESMTP $mail_name ($mail_version)  ← 找到这一行,接此行添加如下行:
smtpd_banner = $myhostname ESMTP unknow  ← 添加这一行,不显示SMTP服务器的相关信息

在配置文件的文尾,添加如下行:

smtpd_sasl_auth_enable = yes  ← 服务器使用SMTP认证
smtpd_sasl_local_domain = $myhostname  ← 指定SMTP认证的本地域名(主机名)
smtpd_sasl_security_options = noanonymous   ← 不允许匿名的方式认证
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
message_size_limit = 15728640  ← 规定邮件最大尺寸为15MB

[2] 配置SMTP认证的相关选项

  为了提高安全性,我们不将系统用户的密码作为相应用户SMTP认证的密码,而将在后面为用户建立SMTP认证专用的密码。

[root@sample ~]# vi /usr/lib/sasl2/smtpd.conf  ← 编辑SMTP认证的配置文件

pwcheck_method: saslauthd  ← 找到此行,将“saslauthd”改为“auxprop”
 ↓
pwcheck_method: auxprop  ← 不使用系统用户密码作为用户的SMTP认证密码

[root@sample ~]# vi /etc/sysconfig/saslauthd
MECH=shadow  ← 找到这一行,在前面加#
 ↓
#MECH=shadow  ← 不使用shadow机制

FLAGS=  ← 找到此行,在等号后面添加“sasldb”
 ↓
FLAGS=sasldb   ← 定义认证方式为sasldb2

[3] 建立用户的邮箱目录

  首先建立用户模板下的邮箱目录,以便于建立新用户时,相应用户的邮箱目录自动被建立。

[root@sample ~]# mkdir /etc/skel/Maildir  ← 在用户模板下建立用户邮箱目录

[root@sample ~]# chmod 700 /etc/skel/Maildir  ← 设置用户邮箱目录属性为700

  然后再为已经存在的用户建立相应邮箱目录。

[root@sample ~]# mkdir /home/centospub/Maildir  ← 为用户(这里以centospub用户为例)建立邮箱目录

[root@sample ~]# chmod 700 /home/centospub/Maildir  ← 设置该用户邮箱目录属性为700

[root@sample ~]# chown centospub. /home/centospub/Maildir  ← 设置该用户邮箱目录为该用户所有

[4] 为用户设置SMTP认证密码

[root@sample ~]# saslpasswd2 -u sample.centospub.com -c centospub  ← 为centospub用户设置SMTP认证密码

Password:  ← 在这里输入密码(不会显示)
Again (for verification):  ← 再次输入密码

[5] 改变SALS的属性及归属

[root@sample ~]# chgrp postfix /etc/sasldb2  ← 将数据库归属改为postfix,

[root@sample ~]# chmod 640 /etc/sasldb2  ← 将数据库属性改为640

[6] 关闭sendmail服务及设置默认MTA

  因为在用Postfix作为SMTP服务器的前提下,我们不准备再用sendmail,所以将sendmail服务关掉,以确保安全及节省系统资源。

[root@sample ~]# /etc/rc.d/init.d/sendmail stop  ← 关闭sendmail服务

Shutting down sendmail:         [ OK ]
Shutting down sm-client:         [ OK ]

[root@sample ~]# chkconfig sendmail off  ← 关闭sendmail自启动

[root@sample ~]# chkconfig --list sendmail  ← **sendmail自启动已被关闭(都为off就OK)
sendmail 0:off 1:off 2:off 3:off 4:off 5:off 6:off

  然后再将默认的MTA设置为Postfix。

[root@sample ~]# alternatives --config mta  ← 设置默认MTA There are 2 programs which provide 'mta'.
Selection Command
-----------------------------------------------
*+ 1 /usr/sbin/sendmail.sendmail  ← 当前状态:sendmail为默认MTA
 2 /usr/sbin/sendmail.postfix
Enter to keep the current selection[+], or type selection number: 2  ← 在这里输入2,使Postfix成为默认MTA

启动相应服务

  最后,启动SMTP认证及Postfix服务,并设置相应服务为自启动。

[root@sample ~]# chkconfig saslauthd on  ← 将SMTP-Auth设置为自启动

[root@sample ~]# chkconfig --list saslauthd  ← **SMTP-Auth服务状态
saslauthd 0:off 1:off 2:on 3:on 4:on 5:on 6:off  ← **2~5为on的状态就OK

[root@sample ~]# /etc/rc.d/init.d/saslauthd start  ← 启动SMTP-Auth

Starting saslauthd:           [ OK ]

[root@sample ~]# chkconfig postfix on  ← 将Postfix设置为自启动

[root@sample ~]# chkconfig --list postfix  ← **Postfix服务状态
postfix 0:off 1:off 2:on 3:on 4:on 5:on 6:off  ← **2~5为on的状态就OK

[root@sample ~]# /etc/rc.d/init.d/postfix start  ← 启动Postfix

Starting postfix:            [ OK ]

  至此,就完成了SMTP服务器方面的配置,但目前只具从备客户端通过服务器发送邮件的功能。做为完整的邮件服务器,还需具备从客户端通过POP/IMAP协议接受邮件到本地的功能。POP/IMAP服务器的构建请参见下一节 < POP / IMAP 服务器的构建( Dovecot ) >。



前言

  POP / IMAP 是 MUA 从邮件服务器中读取邮件时使用的协议。其中,与 POP3 是从邮件服务器中下载邮件比起来,IMAP4 则是将邮件留在服务器端直接对邮件进行管理、操作。这里,我们用 Dovecot 来实现对 POP3 及 IMAP4 等协议支持的邮件接收服务器的搭建。

  Dovecot 是一个比较新的软件,由 Timo Sirainen 开发,最初发布于 2002年7月。作者将安全性考虑在第一,所以 Dovecot 在安全性方面比较出众。另外,Dovecot 支持多种认证方式,所以在功能方面也比较符合一般的应用。

安装 Dovecot

  首先,安装 Dovecot 。

[root@sample ~]# yum -y install dovecot  ← 在线安装 Dovecot

Setting up Install Process
Setting up repositories
dag 100% |=========================| 1.1 kB 00:00
update 100% |=========================| 951 B 00:00
base 100% |=========================| 1.1 kB 00:00
addons 100% |=========================| 951 B 00:00
extras 100% |=========================| 1.1 kB 00:00
Reading repository metadata in from local files
Parsing package install arguments
Resolving Dependencies
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for dovecot to pack into transaction set.
dovecot-0.99.11-4.EL4.i38 100% |=========================| 15 kB 00:00
---> Package dovecot.i386 0:0.99.11-4.EL4 set to be updated
--> Running transaction check
--> Processing Dependency: libmysqlclient.so.14(libmysqlclient_14) for package: dovecot
--> Processing Dependency: libpq.so.3 for package: dovecot
--> Processing Dependency: libmysqlclient.so.14 for package: dovecot
--> Restarting Dependency Resolution with new changes.
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for postgresql-libs to pack into transaction set.
postgresql-libs-7.4.13-2. 100% |=========================| 11 kB 00:00
---> Package postgresql-libs.i386 0:7.4.13-2.RHEL4.1 set to be updated
---> Downloading header for mysql to pack into transaction set.
mysql-4.1.20-1.RHEL4.1.i3 100% |=========================| 35 kB 00:00
---> Package mysql.i386 0:4.1.20-1.RHEL4.1 set to be updated
--> Running transaction check
--> Processing Dependency: perl(DBI) for package: mysql
--> Restarting Dependency Resolution with new changes.
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for perl-DBI to pack into transaction set.
perl-DBI-1.40-8.i386.rpm 100% |=========================| 11 kB 00:00
---> Package perl-DBI.i386 0:1.40-8 set to be updated
--> Running transaction check Dependencies Resolved
=============================================================================
Package Arch Version Repository Size
=============================================================================
Installing:
dovecot i386 0.99.11-4.EL4 base 612 k
Installing for dependencies:
mysql i386 4.1.20-1.RHEL4.1 base 2.9 M
perl-DBI i386 1.40-8 base 466 k
postgresql-libs i386 7.4.13-2.RHEL4.1 base 146 k
Transaction Summary
=============================================================================
Install 4 Package(s)
Update 0 Package(s)
Remove 0 Package(s)
Total download size: 4.1 M
Downloading Packages:
(1/4): dovecot-0.99.11-4. 100% |=========================| 612 kB 00:00
(2/4): postgresql-libs-7. 100% |=========================| 146 kB 00:00
(3/4): mysql-4.1.20-1.RHE 100% |=========================| 2.9 MB 00:02
(4/4): perl-DBI-1.40-8.i3 100% |=========================| 466 kB 00:00
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing: perl-DBI ######################### [1/4]
Installing: mysql ######################### [2/4]
Installing: postgresql-libs ######################### [3/4]
Installing: dovecot ######################### [4/4]
Installed: dovecot.i386 0:0.99.11-4.EL4
Dependency Installed: mysql.i386 0:4.1.20-1.RHEL4.1 perl-DBI.i386 0:1.40-8 postgresql-libs.i386 0:7.4.13-2.RHEL4.1
Complete!

配置 Dovecot
  然后,修改相应配置文件,配置 Dovecot 。
[root@sample ~]# vi /etc/dovecot.conf  ← 编辑Dovecot 的配置文件

#protocols = imap imaps  ← 找到这一行,将协议设置为imap与pop3
 ↓
protocols = imap pop3  ← 变为此状态

#default_mail_env =  ← 找到这一行,定义邮件目录
 ↓
default_mail_env = maildir:~/Maildir  ← 定义邮件目录为用户目录下的Maildir目录

添加防火墙规则
  由于 POP3 协议与 IMAP4 协议要分别用到110号和143号端口,所以在启动服务前,配置防火墙,开通这两个端口。
[root@sample ~]# vi /etc/sysconfig/iptables  ← 编辑防火墙规则

-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 25 -j ACCEPT  ← 找到此行,接着添加如下两行:
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 110 -j ACCEPT  ← 允许POP使用的110号端口
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 143 -j ACCEPT  ← 允许IMAP使用的143号端口

[root@sample ~]# /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 ]

启动 Dovecot

  最后,启动 Dovecot ,并将其设置为自启动。

[root@sample ~]# chkconfig dovecot on  ← 设置Dovecot为自启动

[root@sample ~]# chkconfig --list dovecot
dovecot 0:off 1:off 2:on 3:on 4:on 5:on 6:off  ← **2~5为on的状态就OK

[root@sample ~]# /etc/rc.d/init.d/dovecot start  ← 启动Dovecot服务

Starting Dovecot Imap:        [ OK ]

  至此,配合Postfix,就可以通过E-mail客户端软件实现电子邮件的收发了。

前  言

  通常,一个域名都对应一个邮件服务器,但在一些时候,为了资源的活用,可以将多个域名应用于同一个邮件服务器。好多虚拟主机提供商也在用此功能提供虚拟主机用户对应的邮件服务。

  当多个域名应用于同一个邮件服务器时,我们可以将这些域名指向邮件服务器的主域名(在Postfix中被设置的域名)。也就是说,通过这些虚拟域名(非主域名)发送到服务器的邮件,将被视作发送至主域名的邮件,而被邮件服务器接收。这个过程也同样可以精确到用户,比如发送到虚拟域名下的某个用户的邮件,可以被视作发送给邮件服务器上某个实际存在的用户,而被该用户接收。

  以本站为例,目前有两个域名同时应用于本站所在的邮件服务器。它们分别为:digeast.no-ip.info 和 centospub.com 。在邮件服务器(Postfix)设置中 centospub.com 被设置为了主域名,digeast.no-ip.info 也指向邮件服务器,但在没有定义虚拟域名规则之前,它无法直接被应用于邮件服务器(具体表现就是:别人通过youruser@digeast.no-ip.info发送给你邮件会发送不成功)。但通过配置虚拟域名,可以实现,发送给user@digeast.no-ip.info的邮件 == user@centospub.com

前  言

[1] 对 Postfix 的虚拟域名相关选项进行配置。

[root@sample ~]# vi /etc/postfix/main.cf  ← 编辑Postfix的配置文件,在文尾添加如下行:

virtual_alias_maps= hash:/etc/postfix/virtual  ← 定义虚拟域名转送规则文件
[2] 定义虚拟域名转送规则。
[root@sample ~]# vi /etc/postfix/virtual  ← 编辑Postfix的虚拟域名相关配置文件,在文尾添加如下行

digeast.no-ip.info anything
@digeast.no-ip.info @centospub.com

[root@sample ~]# postmap /etc/postfix/virtual  ← 更新虚拟域名规则
  以上一本站为例,定义规则:将发送至 user@digeast.no-ip.info 的邮件视作发送至 user@centospub.com

[3] 重新启动Postfix,使设置生效。
[root@sample ~]# /etc/rc.d/init.d/postfix restart

Shutting down postfix:         [ OK ]
Starting postfix:            [ OK ]
[4] 测试。

  最后,发送测试邮件到虚拟域名(本站为digeast.no-ip.info,请根据你的实际情况设置),然后接收邮件,**能够收到邮件。


 < 用 SSL 对邮件加密的支持 > (最近更新日:2006/10/18)
前  言

  通常,我们发送的邮件在传输过程中都采用明文传输。当发送重要信息的时候,仍然存在邮件被第三方获取,泄露隐私及密码等等的安全隐患。在 Web 服务器中,通过用 SSL 实现对 HTTPS 协议的支持,实现了对传输内容的加密,在邮件服务器中,我们也同样能够依靠 SSL 来实现对邮件的加密,从而提高通过用邮件传递信息的安全性。

证书与密钥的**

  在这里,可以为邮件服务器建立新的证书,但为了管理上的便利性,我们直接引用 Web 服务器的证书,作为邮件服务器的证书。

  首先** Web 服务器证书的存在。

[root@sample ~]# ls -l /etc/httpd/conf/ssl.crt/server.crt  ← **证书的存在性

-rw-r--r-- 1 root root 956 Oct 14 08:51 /etc/httpd/conf/ssl.crt/server.crt  ← 证书存在

[root@sample ~]# ls -l /etc/httpd/conf/ssl.key/server.key  ← **密钥的存在性

-rw------- 1 root root 887 Oct 14 08:49 /etc/httpd/conf/ssl.key/server.key  ← 密钥存在

  如果以上**,没有发现相关的证书和密钥的存在,请参见 “让服务器支持安全 HTTP 协议( HTTPS )” 中的方法来建立相关的证书和密钥。

SMTP服务器(Postfix)方面的相关设置

[1] 编辑 Postfix 的 mail.cf 配置文件。

[root@sample ~]# vi /etc/postfix/main.cf  ← 编辑 Postfix 配置文件,在文尾添加如下行:

smtpd_use_tls = yes
smtpd_tls_session_cache_database = btree:/etc/postfix/smtpd_scache
smtpd_tls_cert_file = /etc/httpd/conf/ssl.crt/server.crt
smtpd_tls_key_file = /etc/httpd/conf/ssl.key/server.key

[2] 编辑 Postfix 的 master.cf 配置文件。

[root@sample ~]# vi /etc/postfix/master.cf  ← 编辑 master.cf

smtp   inet   n   -   n   -   -   smtpd  ← 找到此行,在行首加“#”
 ↓
#smtp   inet   n   -   n   -   -   smtpd  ← 改为此状态,禁用SMTP协议

#smtps   inet   n   -   n   -   -   smtpd  ← 找到此行,去掉行首的“#”
 ↓
smtps   inet   n   -   n   -   -   smtpd  ← 改为此状态,使用SMTPS协议

# -o smtpd_tls_wrappermode=yes -o smtpd_sasl_auth_enable=yes  ← 找到此行,去掉行首的“#”
 ↓
-o smtpd_tls_wrappermode=yes -o smtpd_sasl_auth_enable=yes  ← 改为此状态

[3] 编辑 Dovecot 的配置文件。

[root@sample ~]# vi /etc/dovecot.conf  ← 编辑 Dovecot 的配置文件

protocols = imap pop3  ← 找到此行,将“=”后面的部分改为如下状态
 ↓
protocols = imaps pop3s  ← 改为此状态,让其只支持imaps和pop3s协议

#ssl_disable = no  ← 找到此行,去掉行首的“#”
 ↓
ssl_disable = no  ← 改为此状态,让其支持 SSL 及 TLS

#ssl_cert_file = /usr/share/ssl/certs/dovecot.pem  ← 找到此行,去掉行首的“#”,并指定证书所在位置
 ↓
ssl_cert_file =/etc/httpd/conf/ssl.crt/server.crt  ← 改为此状态,指定其证书为 Apache 的证书
 ↓
#ssl_key_file = /usr/share/ssl/private/dovecot.pem  ← 找到此行,去掉行首的“#”,并指定密钥所在位置

ssl_key_file = /etc/httpd/conf/ssl.key/server.key   ← 改为此状态,指定其密钥为 Apache 的密钥

[4] 编辑防火墙规则,打开相应端口。

[root@sample ~]# vi /etc/sysconfig/iptables  ← 编辑防火墙规则

-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 25 -j ACCEPT  ← 找到此行,接着添加如下行:
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 465 -j ACCEPT  ← 允许SMTPS的465号端口
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 995 -j ACCEPT  ← 允许POP3S的995号端口
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 993 -j ACCEPT  ← 允许IMAPS的993号端口

重新起动相关服务,使设置生效

  最后,重新启动所有相关的服务,使刚刚的设置生效。

[root@sample ~]# /etc/rc.d/init.d/postfix restart  ← 重新启动 Postfix

Shutting down postfix:         [ OK ]
Starting postfix:           [ OK ]

[root@sample ~]# /etc/rc.d/init.d/dovecot restart  ← 重新启动 Dovecot

Stopping Dovecot Imap:        [ OK ]
Starting Dovecot Imap:         [ OK ]

[root@sample ~]# /etc/rc.d/init.d/iptables restart  ← 重新启动 iptables

Flushing firewall rules:          [ OK ]
Setting chains to policy ACCEPT: filter   [ OK ]
Unloading iptables modules:       [ OK ]
Applying iptables firewall rules:      [ OK ]

邮件客户端的设置

  这里,邮件客户端的设置以 Thunderbird 为例。

* SMTP 方面:

  在 SMTP 服务器设置中,选择 SSL 方式。使用 Thunderbird 的情况下,选择 SSL 后,端口号会自动变成 465。其它邮件客户端软件请根据实际情况正确设置。



* POP 方面:

  在 POP 服务器设置中,选择 SSL 方式。使用 Thunderbird 的情况下,选择 SSL 后,端口号会自动变成 995。其它邮件客户端软件请根据实际情况正确设置。



  在发送或接收邮件时,会弹出服务器证书相关的信息,如下:



  选择“确定”接受服务器证书。



  再次点击”确定“信任此服务器证书。

  最后发送邮件到服务器的相应用户,并**能够接收。
 楼主| dirtysea 发表于 2010-6-30 14:25:21 | 显示全部楼层
Postfix维护与管理技巧
又花了几天研究起Postfix了,听说EMOS1.4快出现了,采用Dspam防垃圾邮件技术,所以很期待,不过目前测试环境还是EMOS1.3,以下是使用中的一些记录,也许那天会用得到.
1,快速查出系统有那些值得注意的事情:
#egrep ‘(reject|warning|error|fatal|panic):’ /var/log/maillog
2,检查main.cf配置文件是否正确:
#postfix check
3,重启Postfix服务与重新载入配置:
#service postfix restart
#postfix reload

4,一封邮件最多几位收件人限制,默认1000,修改main.cf
smtpd_recipient_limit = 100
5,单封邮件容量上限,默认10MB,修改main.cf
message_size_limit = 10000000
6,客户端出错或恶意错误连接可用以下限制main.cf
smtpd_error_sleep_time = 1s
smtpd_soft_error_limit = 10
smtpd_hard_error_limit = 20
7,改变投递地址,假如用户kevin@23day.com更换了新地址,使用以下方法提示其它用户:
(1)在/etc/postifx/main.cf中添加relocated_maps = hash:/etc/postfix/relocated参数
(2)touch /etc/postfix/relocated
在relocated中添加以下信息
kevin@23day.com   chen@23day.com
#postmap /etc/postfix/relocated
#postfix reload
8,网域更换
(1)在/etc/postifx/main.cf中添加relocated_maps = hash:/etc/postfix/relocated参数
(2)touch /etc/postfix/relocated
在relocated中添加以下信息
@23day.com   23day.cn
#postmap /etc/postfix/relocated
#postfix reload
9,邮件队列管理工具postqueue与postsuper
#postqueue -p查看邮件队列
如果队列序号加了*号表示为活动队列
如果队列序号加了!号表示为延期队列
如果队列序号没有*与!号表示为等待队列
#postsuper -d DBA3F1A9删除队列里的邮件
#postsuper -d ALL删除队列里所有的邮件
#postsuper -r ALL重新排队所有邮件
#postcat -q DBA3F1A9查看邮件内容
10,邮件转发设置将所有出站邮件转发到192.168.1.1服务器上main.cf
relayhost = 192.168.1.1
11,针对某个域的转发
#vi /etc/postfix/main.cf 新增transport_maps = hash:/etc/postfix/transport
#vi /etc/postfix/transport
gmail.com  smtp:[192.168.1.10] 设定寄往gmail的邮件从192.168.1.10机器转发出去
#postmap /etc/postfix/transport
#postfix reload
12,CentOS4.7下挂载共享目录
#mount -t cifs -o username=extmailuser,password=”mis[]229″ //192.168.1.122/extmail /mnt
13,配置垃圾邮件策略行为”D_DISCARD->丢弃,D_PASS->通过,D_BOUNCE->返回”
#vi /etc/amavisd.conf 第115行到118行
$final_virus_destiny      = D_PASS;
$final_banned_destiny     = D_BOUNCE;
$final_spam_destiny       = D_PASS;
$final_bad_header_destiny = D_PASS;
14,单网卡又IP配置
#cd /etc/sysconfig/network-scripts/
#cp ifcfg-eth0 ifcfg-eth0:0
编辑ifcfg-eth0:0里的DEVICE参数为eth0:0
#service network restart
15,CentOS4.7使用代理上网(命令行上网)
编辑/etc/profile文件
#vi /etc/profile
http_proxy=192.168.1.1:3128  代理分别指定http,https,ftp
https_proxy=192.168.1.1:3128
ftp_proxy=192.168.1.1:3128
no_proxy=192.168.1.  局域网不使用代理
export http_proxy https_proxy ftp_proxy no_proxy
保存重启机器
16,拒绝某一IP发送邮件服务器(方法很多)
#vi /etc/postfix/main.cf
smtpd_client_restrictions =
check_client_access hash:/etc/postfix/client_access
#vi /etc/postfix/client_access
192.168.1.5    REJECT   拒绝192.168.1.5发送邮件
17,使用代理升級CentOS(yum)
#vi /etc/yum.conf
proxy=http://192.168.1.55:3128
proxy_username=yum-user
proxy_password=yum-passwd
18,邮件队列处理方式4种队列
收件(incoming),活动(active),延迟(deferred),故障(corrupt)
新邮件第一站是”收件队列”如果系统资料空闲,会转到”活动队列”,如果投递失败会被移入”延迟队列”
19,投递操作
Postfix以收件人地址类型判断如何投递邮件,主要地址类型及投递顺序为本地(local),虚拟别名(Virtual alias),虚拟邮箱(virtual mailbox)以及转发(relay).
20,clamav杀毒软件RPM下载地址http://packages.sw.be/clamav/
下载最新版然后使用rpm -Uvh升级.
21,mysql导出查询结果
mysql>select name,username from mailbox into outfile ‘mail.txt’;
默认导出文件在/var/lib/mysql/extmail目录
21,全局通讯录生成方法
首先使用21项导入数据,然后使用excel编辑保存成csv档,再将数据复制到globabook.cf中就可以了(官方现有批perl工具,非常好用,这是不知道这工具之前想的办法)
22,添加静态路更新freshclam(未验证是否成功)
61.177.194.0    192.168.1.118  255.255.255.0
23,使用rsync同步home目录
Server配置:
#vi /etc/xinetd.d/rsync 将disable改为no
#vi /etc/rsyncd.conf 添加以下内容
[extmail]
path=/home/domains
auth users=admin
uid=root
gid=root
secrets file=/etc/rsyncd.secrets
read only=yes
#vi /etc/rsyncd.secrets 添加以下内容
admin:password
#chmod 600 /etc/rsyncd.secrets
#/etc/xinit.d/xinetd restart
Client配置:
vi /etc/rsyncd.secrets添加密码”password”
#rsync -vzrtopg –delete –progress admin@192.168.1.1::extmail /home/domains –password-file=/etc/rsyncd.secretes
24, freshclam使用代理升级病毒库(其实很简单,找得好辛苦)
#vi /etc/freshclam.conf 将此配置文件的以下代理设置打开就可以了
HTTPProxyServer 192.168.1.9
HTTPProxyPort 3128

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|小黑屋|手机版|Archiver|运维之家

GMT+8, 2024-4-20 15:20 , Processed in 0.141643 second(s), 14 queries .

Powered by Dirtysea

© 2008-2020 Dirtysea.com.

快速回复 返回顶部 返回列表