postfix郵件服務器搭建

兩臺不用域不同網段的郵件服務器互發郵件

開三臺虛擬機,第一臺做192.168.1.0/24網段的vfast.com域的郵件服務器,第二臺作爲DNS服務器作爲兩個域的郵件服務器的DNS服務器,第三臺作爲192.168.2.0/24網段的benet.com域的郵件服務器;第一臺網卡橋接方式爲VMnet2,第二臺兩塊網卡分別橋接爲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收件情況如下:



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章