iRedMail安装及整合AD

9,132次阅读
没有评论

共计 5824 个字符,预计需要花费 15 分钟才能阅读完成。

准备上开源邮件系统,现在各种测试。

环境:AD 主机:ad.szmaxcent.com 192.168.100.31 Win Server 2008 R2

         Mail 主机:mail.szmaxcent.com 192.168.100.98 CentOS 6.6

 
一、安装 iRedMail

1. 安装前环境配置

修改主机名

# vi /etc/sysconfig/network

NETWORKING=yes
HOSTNAME=mail.szmaxcent.com
GATEWAY=192.168.100.1

#vi /etc/hosts

127.0.0.1   mail.szmaxcent.com  mail    localhost localhost.localdomain localhost4 localhost4.localdomain4
关闭 Selinux

#vi /etc/selinux/config

SELINUX=disabled

重启服务器

#reboot

2. 安装 iRedMail

下载 iRedMail, 目前版本为 0.9.0

# wget http://www.iredmail.com/iRedMail-0.9.0.tar.bz2

解压下载的 iRedMail 到家目录下

#tar –jxvf iRedMail-0.9.0.tar.bz2 –C ~

因安装脚本默认使用 iredmail.org 域名,但这域名被伟大的 GFW 给挡了,所以得先修改~/iRedMail0.9.0/pkgs/get_all.sh 脚本

# vi ~/iRedMail-0.9.0/pkgs/get_all.sh

修改第 38 行 export IREDMAIL_MIRROR=”${IREDMAIL_MIRROR:=http://iredmail.org}”中的 iredmail.org 改为网站的 IP 地址
173.254.22.21,不过最好是自己 ping 一下 iredmail.org 的域名看看是什么 IP,有作者改 IP 的可能。

执行 #bash ~/iRedMail0.9.0/iRedMail.sh

执行后会安装 repl 的源及一些相关的依赖包,然后跳入欢迎界面

image

选择 Yes 后进去下一步

image

注意,红色框内填写 Mailbox 存储地址,这里我就先用默认的了,生产环境的话会专门分一个区或者挂载相关设备来存储邮件,当然,直接把分区挂载到默认的 /var 也可以的。

继继下一步

image

选择 WEB 服务程序,有两个可选,这个见仁见智吧,各有优劣,我这里选用了 Apche。

image

选择邮件帐号存储方式,因为我们要与 AD 整合,这里必须使用 OpenLDAP。

image

输入 LDAP Root DN, 这里我输入与 AD 相同的 DN,dc=szmaxcent,dc=com

image

设置 LDAP 管理员 Manager 的密码。

image

设置 MySQL 管理员 root 的密码。

image

设置第一个虚拟邮件域,也就是邮件地址 @后面的部分,我这里是 szmaxcent.com

image

设置默认管理员邮箱 postmaster@szmaxcent.com 的密码

image

选择安装组件。

1.DKIM,这是一项数字签名以防止伪造你的域名发送垃圾邮件的利器,看需求选装吧。

2.iRedAdmin,这是项目作者的作品,用于管理邮件域和邮箱,但是由于我们要集成 AD,所以这个也就不起作用了,不需要安装。

3.Roundcubemail,这是个优秀的开源 WebMail 程序,有丰富的插件可供使用,如果需要 WebMail 服务就必须要安装了。

4.SoGo,一个群件系统,提供类似于 OUTLOOK 的服务,支持 Microsoft ActiveSync,这个也是看需求吧

5.Awstats, 这是一个很棒的 WEB 日志分析工具,看需求吧,推荐安装

6.Fail2ban, 一款安全工具,能够将暴力破解密码的用户 IP 直接封锁,可定义封锁时间。推荐安装

选择完后会出现以下提示,会将以上设置过程中的设定保存在 iRedMail 的安装目录下的 config 文件中,安装完成后最好是删除它,因为设定的密码之类都是明文保存在这个文件中的。
Configuration completed.

*************************************************************************
***************************** WARNING ***********************************
*************************************************************************
*                                                                       *
* Below file contains sensitive infomation (username/password), please  *
* do remember to *MOVE* it to a safe place after installation.          *
*                                                                       *
*   * /root/iRedMail-0.9.0/config
*                                                                       *
*************************************************************************
< Question > Continue? [y|N]y

输入 y 开始安装,各个组件会从网络下载并安装。
安装完成后会看到以下提示

********************************************************************
* Congratulations, mail server setup completed successfully. Please
* read below file for more information:
*
*   – /root/iRedMail-0.9.0/iRedMail.tips
*
* And it’s sent to your mail account postmaster@szmaxcent.com.
*
* Please reboot your system to enable mail services.
*
********************************************************************

安装的各个软件的路径及配置文件路径,并以将此文件发送到默认管理邮箱 postmaster 中。

注意:此文件中也有保存明文密码,建议删除此文或修改文件中的密码部分。

至此 iRedMail 安装完成,重启服务器。

 

二、整合 AD 验证

1. 在 AD 服务器的 Mailusers 这个 OU 里建立用户 imail 以用于验证,用户权限设定为 domain guests.

2. 在邮件服务器上验证连接

# ldapsearch -x -h dc.szmaxcent.com -D ‘imail’ -W -b ‘ou=mailusers,dc=szmaxcent,dc=com’
Enter LDAP Password:     #输入 AD 用户 imail 的密码

3. 清除部份 postconf 配置

# postconf -e virtual_alias_maps=”
# postconf -e sender_bcc_maps=”
# postconf -e recipient_bcc_maps=”
# postconf -e relay_domains=”
# postconf -e relay_recipient_maps=”

4. 设置邮件发件域和收件域

# postconf -e smtpd_sasl_local_domain=’szmaxcent.com’
# postconf -e virtual_mailbox_domains=’szmaxcent.com’

5. 设置传输索引

# postconf -e transport_maps=’hash:/etc/postfix/transport’
# postmap hash:/etc/postfix/transport
# vi /tc/postfix/transport
szmaxcent.com   dovecot

6. 设置验证发件人

# postconf -e smtpd_sender_login_maps=’proxy:ldap:/etc/postfix/ad_sender_login_maps.cf’
# vi /etc/postfix/ad_sender_maps.cf
server_host = dc.szmaxcent.com
server_port = 389
version = 3
bind = yes
start_tls = no
bind_dn = imail
bind_pw = imail_user_password
search_base = ou=mailusers,dc=szmaxcent,dc=com
scope = sub
query_filter = (&(userPrincipalName=%s)(objectClass=person)(!(userAccountControl:1.2.840.113556.1.4.803:=2)))
result_attribute = userPrincipalName
debuglevel = 0

7. 设置验证收件人

# postconf -e virtual_mailbox_maps=’proxy:ldap:/etc/postfix/ad_virtual_mailbox_maps.cf’
# vi /etc/postfix/ad_virtual_mailbox_maps.cf
server_host = dc.szmaxcent.com
server_port = 389
version = 3
bind = yes
start_tls = no
bind_dn = imail
bind_pw = imail_user_password
search_base = ou=mailusers,dc=szmaxcent,dc=com
scope = sub
query_filter = (&(objectclass=person)(userPrincipalName=%s))
result_attribute = userPrincipalName
result_format = %d/%u/Maildir/
debuglevel = 0

8. 设置验证邮件组

# postconf -e virtual_alias_maps=’proxy:ldap:/etc/postfix/ad_virtual_group_maps.cf’
# vi /etc/postfix/ad_virtual_group_maps.cf
server_host = dc.szmaxcent.com
server_port = 389
version = 3
bind = yes
start_tls = no
bind_dn = imail
bind_pw = imail_user_password
search_base = ou=mailusers,dc=szmaxcent,dc=com
scope = sub
query_filter = (&(objectClass=group)(sAMAccountName=%u))
special_result_attribute = member
leaf_result_attribute = mail
result_attribute = userPrincipalName
debuglevel = 0

9. 删除 iRedAPD 相关设置

# vi /etc/postfix/main.cf
在 720 行和 721 行左右找到check_policy_service inet:127.0.0.1:7777 并删除

10. 验证以上设置

在 Mailusers 下新建用户 mailtest, 组 group, 组中包含 mailtest,imail 两个用户。

验证发件人

# postmap -q mailtest@szmaxcent.com ldap:/etc/postfix/ad_sender_maps.cf
mailtest@szmaxcent.com

验证收件箱地址

# postmap -q mailtest@szmaxcent.com ldap:/etc/postfix/ad_virtual_mailbox_maps.cf
szmaxcent.com/mailtest/Maildir/

验证邮件地址组

# postmap -q group@szmaxcent.com ldap:/etc/postfix/ad_virtual_group_maps.cf
mailtest@szmaxcent.com,imail@szmaxcent.com

11. 整合 AD 集成 Dovecot, 让用户可以使用 POP3,IMAP 服务

hosts = dc.szmaxcent.com:389
ldap_version = 3
auth_bind = yes
dn = imail
dnpass = imail_user_password
base = ou=mailusers,dc=szmaxcent,dc=com
scope = subtree
deref = never
user_filter = (&(userPrincipalName=%u)(objectClass=person)(!(userAccountControl:1.2.840.113556.1.4.803:=2)))
pass_filter = (&(userPrincipalName=%u)(objectClass=person)(!(userAccountControl:1.2.840.113556.1.4.803:=2)))
pass_attrs = userPassword=password
default_pass_scheme = CRYPT
user_attrs = =home=/var/vmail/vmail1/%Ld/%Ln/Maildir/,=mail=maildir:/var/vmail/vmail1/%Ld/%Ln/Maildir/

正文完
 
Winter
版权声明:本站原创文章,由 Winter 2015-03-23发表,共计5824字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
评论(没有评论)
验证码