要求:dns eth0 172.17.17.1  eth1 172.17.16.1
邮件服务器:mail.wu.com 172.17.17.2
邮件服务器:mail.vfast.com 172.17.16.2

一、设置dns
首先配置路由和ip转发:
IP转发:
[root@localhost ~]# echo > 1 /proc/sys/net/ipv4/ip_forward
[root@localhost ~]#
[root@localhost ~]# vim /etc/sysctl.conf
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# sysctl -p
net.ipv4.ip_forward = 1
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.default.accept_source_route = 0
kernel.sysrq = 0
kernel.core_uses_pid = 1
net.ipv4.tcp_syncookies = 1
kernel.msgmnb = 65536
kernel.msgmax = 65536
kernel.shmmax = 4294967295
kernel.shmall = 268435456
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# service network restart

安装:[root@localhost ~]# yum install bind*
修改主配置文件:
[root@localhost ~]# vim /var/named/chroot/etc/named.conf
options{
    directory   "/var/named";
};
zone   "wu.com"  {
       type  master;
       file  "wu.com.zone";
};
zone  "vfast.com" {
       type  master;
       file  "wu.com.zone";
};
include "/etc/rndc.key";
~                                                                              

拷贝模板文件
[root@localhost ~]# cp /usr/share/doc/bind-9.3.6/sample/var/named/localhost.zone /var/named/chroot/var/named/wu.com.zone
修改wu.com.zone
         $TTL    86400
@               IN SOA  @       root (
                                        42              ; serial (d. adams)
                                        3H              ; refresh
                                        15M             ; retry
                                        1W              ; expiry
                                        1D )            ; minimum

wu.com.         IN NS           mail.wu.com.
mail.wu.com.    IN A            172.17.17.2
wu.com.         IN MX 10        mail.wu.com.
vfast.com.      IN NS           mail.vfast.com.
mail.vfast.com. IN A            172.17.16.2
vfast.com.      IN MX 10        mail.vfast.com.

将hosts文件里的内容清空。

启动dns
[root@localhost ~]# service named restart
停止 named:                                               [确定]
启动 named:                                               [确定]
[root@localhost ~]#

测试:
[root@localhost ~]# host mail.vfast.com
mail.vfast.com has address 172.17.16.2
[root@localhost ~]# host mail.wu.com
mail.wu.com has address 172.17.17.2
[root@localhost ~]#

二、配置邮件服务器mail.wu.com
配置路由:
[root@mail ~]# route add default gw 172.17.17.1
[root@mail ~]# service network restart
正在关闭接口 eth0:                                        [确定]
关闭环回接口:                                             [确定]
弹出环回接口:                                             [确定]
弹出界面 eth0:                                            [确定]

关闭sendmail:[root@mail ~]# service sendmail status
sendmail 已停
[root@mail ~]# chkconfig sendmail off
[root@mail ~]#
修改resolv.conf
[root@mail ~]# vim /etc/resolv.conf

nameserver 172.17.17.1

安装postfix:
[root@mail ~]# yum install postfix -y

修改主配置文件:
[root@mail ~]# vim /etc/postfix/main.cf
myhostname = mail.wu.com

mydomain = wu.com
 
myorigin = $mydomain

inet_interfaces = all

mydestination = $myhostname, $mydomain

mynetworks = 172.17.17.0/24, 172.17.16.0/24, 127.0.0.0/8

relay_domains = wu.com, vfast.com

安装dovecot:
[root@mail ~]# yum install dovecot -y
修改配置文件:
[root@mail ~]# vim /etc/dovecot.conf
protocols = pop3 pop3s
protocol imap {
    listen = *:10143
    ssl_listen = *:10943
#     ..
 }
启动:
[root@mail ~]# /etc/init.d/dovecot start
启动 Dovecot Imap:                                        [确定]
[root@mail ~]#
加入启动项:
[root@mail ~]# chkconfig dovecot on
[root@mail ~]#

安装IMAP:
[root@mail ~]# yum install cyrus-imapd cyrus-imapd-devel -y
启动:
[root@mail ~]# /etc/init.d/cyrus-imapd start
导入 cyrus-imapd 数据库:                                  [确定]
启动 cyrus-imapd:                                         [确定]
[root@mail ~]#
加入启动项:
[root@mail ~]# chkconfig cyrus-imapd on
[root@mail ~]#
修改postfix的主配置文件:
[root@mail ~]# vim /etc/postfix/main.cf
在末尾加入:
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain = ''
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
broken_sasl_auth_clients = yes
smtpd_client_restrictions = permit_sasl_authenticated
smtpd_sasl_security_options = noanonymous

重启postfix:
[root@mail ~]# service postfix restart
关闭 postfix:                                             [确定]
启动 postfix:                                             [确定]
[root@mail ~]#
修改cyrus用户的相关内容:
[root@mail ~]# cyradm -u cyrus mail
imclient_connect: unknown host "mail" at /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi/Cyrus/IMAP/Admin.pm line 72.(此错误查看hosts文件)
[root@mail ~]# vim /etc/hosts
[root@mail ~]# cyradm -u cyrus localhost
IMAP Password:
              localhost.localdomain> cm user.test
localhost.localdomain> setquota user.test 5210
quota:5210
localhost.localdomain> quit
[root@mail ~]# su -l cyrus -c /usr/lib/cyrus-imapd/quota
   Quota   % Used     Used Root
    5210        0        0 user.test
[root@mail ~]#


安装squirrelmail
[root@mail ~]# yum install squirrelmail


[root@mail ~]# /usr/share/squirrelmail/config/conf.pl
d--cyrus--2--1--wu.com--3--2--r--4--5--y--r--10--1--zh_CN--2--gb2312--r--s--q


三、配置邮件服务器mail.vfast.com
配置路由:
[root@mail ~]# route add default gw 172.17.16.1
[root@mail ~]# service network restart
正在关闭接口 eth0:                                        [确定]
关闭环回接口:                                             [确定]
弹出环回接口:                                             [确定]
弹出界面 eth0:                                            [确定]

关闭sendmail:[root@mail ~]# service sendmail status
sendmail 已停
[root@mail ~]# chkconfig sendmail off
[root@mail ~]#
修改resolv.conf
[root@mail ~]# vim /etc/resolv.conf

nameserver 172.17.16.1

安装postfix:
[root@mail ~]# yum install postfix -y

修改主配置文件:
[root@mail ~]# vim /etc/postfix/main.cf
myhostname = mail.vfast.com

mydomain = vfast.com
 
myorigin = $mydomain

inet_interfaces = all

mydestination = $myhostname, $mydomain

mynetworks = 172.17.16.0/24, 172.17.17.0/24, 127.0.0.0/8

relay_domains = vfast.com, wu.com

安装dovecot:
[root@mail ~]# yum install dovecot -y
修改配置文件:
[root@mail ~]# vim /etc/dovecot.conf
protocols = pop3 pop3s
protocol imap {
    listen = *:10143
    ssl_listen = *:10943
#     ..
 }
启动:
[root@mail ~]# /etc/init.d/dovecot start
启动 Dovecot Imap:                                        [确定]
[root@mail ~]#
加入启动项:
[root@mail ~]# chkconfig dovecot on
[root@mail ~]#

安装IMAP:
[root@mail ~]# yum install cyrus-imapd cyrus-imapd-devel -y
启动:
[root@mail ~]# /etc/init.d/cyrus-imapd start
导入 cyrus-imapd 数据库:                                  [确定]
启动 cyrus-imapd:                                         [确定]
[root@mail ~]#
加入启动项:
[root@mail ~]# chkconfig cyrus-imapd on
[root@mail ~]#
修改postfix的主配置文件:
[root@mail ~]# vim /etc/postfix/main.cf
在末尾加入:
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain = ''
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
broken_sasl_auth_clients = yes
smtpd_client_restrictions = permit_sasl_authenticated
smtpd_sasl_security_options = noanonymous

重启postfix:
[root@mail ~]# service postfix restart
关闭 postfix:                                             [确定]
启动 postfix:                                             [确定]
[root@mail ~]#
修改cyrus用户的相关内容:
[root@mail ~]# cyradm -u cyrus mail
imclient_connect: unknown host "mail" at /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi/Cyrus/IMAP/Admin.pm line 72.(此错误查看hosts文件)
[root@mail ~]# vim /etc/hosts
[root@mail ~]# cyradm -u cyrus localhost
IMAP Password:
              localhost.localdomain> cm user.test
localhost.localdomain> setquota user.test 5210
quota:5210
localhost.localdomain> quit
[root@mail ~]# su -l cyrus -c /usr/lib/cyrus-imapd/quota
   Quota   % Used     Used Root
    5210        0        0 user.test
[root@mail ~]#


安装squirrelmail
[root@mail ~]# yum install squirrelmail


[root@mail ~]# /usr/share/squirrelmail/config/conf.pl
d--cyrus--2--1--wu.com--3--2--r--4--5--y--r--10--1--zh_CN--2--gb2312--r--s--q

总测试:
在邮件服务器mail.vfast.com中打开浏览器:
输入:mail.vfast.com/webmail
输入用户名和密码,对自己发邮件,并对另一台邮件服务器mail.wu.com发邮件。
另一台邮件服务器的测试同上。