postfix邮件服务器搭建

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

开三台虚拟机,第一台做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地址


2、安装bind,并配置文件
[root@localhost ~ ]#yum -y install bind*
[root@localhost ~ ]#vim /var/named/chroot/etc/named.conf

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

[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

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

4、设置Saslauthd
[root@localhost ~ ]#vim /etc/sysconfig/saslauthd

[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     在配置文件下面添加如下几行:

[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  解除注释如下两段,并改为此样

[root@localhost ~ ]#service dovecot restart
[root@localhost ~ ]#chkconfig dovecot on
7、安装cyrus-imapd 并完成相关配置
[root@localhost ~ ]#yum -y install cyrus-imapd cyrus-imapd-devel

[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

1
vfast.com
3
2
r
4.  General Options
4

5
y
r
10. Languages
10

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

4、设置Saslauthd
[root@localhost ~ ]#vim /etc/sysconfig/saslauthd

[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     在配置文件下面添加如下几行:

[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  解除注释如下两段,并改为此样

[root@localhost ~ ]#service dovecot restart
[root@localhost ~ ]#chkconfig dovecot on
7、安装cyrus-imapd 并完成相关配置
[root@localhost ~ ]#yum -y install cyrus-imapd cyrus-imapd-devel

[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

1
benet.com
3
2
r
4.  General Options
4

5
y
r
10. Languages
10

1
zh_CN
2
gb2312
9、benet.com域的邮件服务器安装完成
(四)测试,不同的域邮件服务器互发邮件测试
1、benet.com域服务器的aa用户发一份邮件给vfast.com域邮件服务器的aa用户
benet.com域用户aa的发件内容如下:

vfast.com域用户aa收件情况如下:

2、测试vfast.com的域用户aa给benet.com的域用户aa发一封邮件
vfast.com域用户的发件内容如下:

benet.com域用户aa收件情况如下:



本文出自 “终点” 博客,谢绝转载!

你可能感兴趣的:(虚拟机,配置文件,IP地址,邮件服务器,的)