两台不用域不同网段的邮件服务器互发邮件

开三台虚拟机,第一台做192.168.1.0/24网段的vfast.com域的邮件服务器,第二台作为DNS服务器作为两个域的邮件服务器的DNS服务器,第三台作为192.168.2.0/24网段的benet.com域的邮件服务器;第一台网卡桥接方式为VMn et2,第二台两块网卡分别桥接为VMnet2和VMnet3,第三台网卡桥接为VMnet3.
(一)首先配置vfast.com域邮件服务器和benet.com域邮件服务器的DNS服务器。
1、配置网卡ip地址
201302071360213970542.png
201302071360214054485.png
2、安装bind,并配置文件
[root@localhost ~ ]#yum -y install bind*
[root@localhost ~ ]#vim /var/named/chroot/etc/named.conf
201302071360214655086.png
3、配置域名解析文件  
[root@localhost ~ ]#cp /usr/share/doc/bind-9.3.6/sample/var/named/localdomain.zone
/var/named/chroot/var/named/vfast.com.zone
[root@localhost ~ ]#vim /var/named/chroot/var/named/vfast.com.zone
201302071360216146259.png
[root@localhost ~ ]#cp /usr/share/doc/bind-9.3.6/sample/var/named/localdomain.zone
/var/named/chroot/var/named/benet.com.zone
[root@localhost ~ ]#vim /var/named/chroot/var/named/benet.com.zone
201302071360216358293.png
4、重启named服务,并加入到开机启动项
[root@localhost ~ ]#service named restart
[root@localhost ~ ]#chkconfig named on
5、DNS配置完成
(二)配置vfast.com域的邮件服务器
1、停止sendmail服务,并设定开机不启动
[root@localhost ~ ]#service sendmail stop
[root@localhost ~ ]#chkconfig sendmail off
2、安装httpd服务,并设定开机启动
[root@localhost ~ ]#yum install httpd
[root@localhost ~ ]#service httpd restart
[root@localhost ~ ]#chkconfig httpd on
3、安装postfix,并完成相关配置
[root@localhost ~ ]#yum -y install postfix
[root@localhost ~ ]#vim /etc/postfix/main.cf
201302071360220017917.png
4、设置Saslauthd
[root@localhost ~ ]#vim /etc/sysconfig/saslauthd
201302071360220780265.png
[root@localhost ~ ]#/etc/init.d/saslauthd restart
[root@localhost ~ ]#chkconfig saslauthd on
5、创建用户aa,并设置密码为‘123.com’
[root@localhost ~ ]#useradd aa
[root@localhost ~ ]#echo "123.com" > passwd --stdin aa
201302071360221259098.png
[root@localhost ~ ]#vim /etc/postfix/main.cf     在配置文件下面添加如下几行:
201302071360221413571.png
[root@localhost ~ ]#service postfix restart 重启动postfix服务
[root@localhost ~ ]#chkconfig postfix  on  加入到开机启动项
6、安装dovecot,并设置开机启动
[root@localhost ~ ]#yum -y install dovecot
[root@localhost ~ ]#vim /etc/dovecot.conf  解除注释如下两段,并改为此样
201302071360221767688.png
[root@localhost ~ ]#service dovecot restart
[root@localhost ~ ]#chkconfig dovecot on
7、安装cyrus-imapd 并完成相关配置
[root@localhost ~ ]#yum -y install cyrus-imapd cyrus-imapd-devel
201302071360222078811.png
[root@localhost ~ ]#cyradm -u aa localhost
IMAP Password:
             localhost.localdomain>cm user.aa
localhost.localdomain>quit

[root@localhost ~ ]#service cyrus-imapd restart
[root@localhost ~ ]#chkconfig cyrus-imapd on
8、安装squirrelmail并进行webmail的后台相关配置
[root@localhost ~ ]#yum -y install squirrelmail
[root@localhost ~ ]#/usr/share/squirrelmail/config/conf.pl
D.  Set pre-defined settings for specific IMAP servers
d
cyrus       = Cyrus IMAP server
cyrus
2.  Server Settings
2
201302071360223059553.png
1
vfast.com
3
2
r
4.  General Options
4
201302071360223297840.png
5
y
r
10. Languages
10
201302071360223467617.png
1
zh_CN
2
gb2312
9、vfast.com域的邮件系统就配置完成了
(三)配置benet.com域的邮件系统
1、停止sendmail服务,并设定开机不启动
[root@localhost ~ ]#service sendmail stop
[root@localhost ~ ]#chkconfig sendmail off
2、安装httpd服务,并设定开机启动
[root@localhost ~ ]#yum install httpd
[root@localhost ~ ]#service httpd restart
[root@localhost ~ ]#chkconfig httpd on
3、安装postfix,并完成相关配置
[root@localhost ~ ]#yum -y install postfix
[root@localhost ~ ]#vim /etc/postfix/main.cf
201302071360224419325.png
4、设置Saslauthd
[root@localhost ~ ]#vim /etc/sysconfig/saslauthd
201302071360220780265.png
[root@localhost ~ ]#/etc/init.d/saslauthd restart
[root@localhost ~ ]#chkconfig saslauthd on
5、创建用户aa,并设置密码为‘123.com’
[root@localhost ~ ]#useradd aa
[root@localhost ~ ]#echo "123.com" > passwd --stdin aa
[root@localhost ~ ]#vim /etc/postfix/main.cf     在配置文件下面添加如下几行:
201302071360221413571.png
[root@localhost ~ ]#service postfix restart 重启动postfix服务
[root@localhost ~ ]#chkconfig postfix  on  加入到开机启动项
6、安装dovecot,并设置开机启动
[root@localhost ~ ]#yum -y install dovecot
[root@localhost ~ ]#vim /etc/dovecot.conf  解除注释如下两段,并改为此样
201302071360221767688.png
[root@localhost ~ ]#service dovecot restart
[root@localhost ~ ]#chkconfig dovecot on
7、安装cyrus-imapd 并完成相关配置
[root@localhost ~ ]#yum -y install cyrus-imapd cyrus-imapd-devel
201302071360222078811.png
[root@localhost ~ ]#cyradm -u aa localhost
IMAP Password:
             localhost.localdomain>cm user.aa
localhost.localdomain>quit

[root@localhost ~ ]#service cyrus-imapd restart
[root@localhost ~ ]#chkconfig cyrus-imapd on
8、安装squirrelmail并进行webmail的后台相关配置
[root@localhost ~ ]#yum -y install squirrelmail
[root@localhost ~ ]#/usr/share/squirrelmail/config/conf.pl
D.  Set pre-defined settings for specific IMAP servers
d
cyrus       = Cyrus IMAP server
cyrus
2.  Server Settings
2
201302071360224976997.png
1
benet.com
3
2
r
4.  General Options
4
201302071360225153877.png
5
y
r
10. Languages
10
201302071360225237320.png
1
zh_CN
2
gb2312
9、benet.com域的邮件服务器安装完成
(四)测试,不同的域邮件服务器互发邮件测试
1、benet.com域服务器的aa用户发一份邮件给vfast.com域邮件服务器的aa用户
benet.com域用户aa的发件内容如下:
201302071360225972913.png
vfast.com域用户aa收件情况如下:
201302071360226045544.png
2、测试vfast.com的域用户aa给benet.com的域用户aa发一封邮件
vfast.com域用户的发件内容如下:
201302071360226237365.png
benet.com域用户aa收件情况如下:
201302071360226331898.png