Windows XP Windows 7 Windows 2003 Windows Vista Windows教程綜合 Linux 系統教程
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟件教程
 Windows教程網 >> 電腦軟件教程 >> 服務器技術 >> 關於服務器 >> 不同網段中的郵件服務器間的郵件轉發

不同網段中的郵件服務器間的郵件轉發

日期:2017/2/8 10:14:46      編輯:關於服務器

應題目要求 需要一台DNS服務器充當2個 mail服務器的域名解析服務器

1.設置DNS服務器  在DNS服務器上增加2塊網卡 並分別設置IP地址。

設置主DNS配置文件.
vim /var/named/chroot/etc/named.conf
options {
      directory "/var/named";
};
zone "hanfangzhou.com" {
      type master;
      file "hanfangzhou.com.zone";
};
zone "laohu.com" {
      type master;
     file "laohu.com.zone";
};


配置2個mail服務器的區域文件


vim /var/named/chroot/var/named/hanfangzhou.com.zone
@               IN SOA  @       root (
                                        42              ; serial (d. adams)
                                        3H              ; refresh
                                        15M             ; retry
                                        1W              ; expiry
                                        1D )            ; minimum
hanfangzhou.com.        IN NS           mail.hanfangzhou.com.
mail                    IN A            192.168.18.48
hanfangzhou.com.        IN MX 10        mail.hanfangzhou.com.
vim /var/named/chroot/var/named/laohu.com.zone

@               IN SOA  @       root (
                                        42              ; serial (d. adams)
                                        3H              ; refresh
                                        15M             ; retry
                                        1W              ; expiry
                                        1D )            ; minimum
laoyu.com.        IN NS            mail.laohu.com.
mail              IN A             10.1.1.2
laoyu.com.        IN MX 10         mail.laohu.com.

重啟DNS服務

service named restart

開啟網卡轉發

 vim /etc/sysctl.conf
net.ipv4.ip_forward = 1

MAIL服務器1(mail.hanfangzhou.com)的設置

停止sendmail服務 關閉開機加載項 service sendmail stop  chkconfig sendmail off
安裝postfix      yum install postfix -y
修改配置文件 vim /etc/postfix/main.cf
69 myhostname = mail.hanfangzhou.com
77 mydomain = hanfangzhou.com
93 myorigin = $mydomain
107 inet_interfaces = all
155 mydestination = $myhostname, localhost.$mydomain, localhost
255 mynetworks = 192.168.18.0/24, 127.0.0.0/8
287 relay_domains = hanfangzhou.com
保存退出

設置SMTP認證配置文件

vim /etc/sysconfig/saslauthd
   MECH=shadow

保存退出

service saslauthd restart

檢查防火牆和SElinux是否關閉
驗證 建立用戶chaoyue
[root@hanfangzhou ~]# useradd chaoyue
[root@hanfangzhou ~]# passwd chaoyue
Changing password for user chaoyue.
New UNIX password:
BAD PASSWORD: it is WAY too short
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
[root@hanfangzhou ~]# testsaslauthd -u chaoyue -p '123'
0: OK "Success."

配置postfix服務與smtp關聯

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

保存退出

service postfix restart         chkconfig postfix on
驗證
perl -MMIME::Base64 -e 'print encode_base64(chaoyue);'
Y2hhb3l1ZQ==
perl -MMIME::Base64 -e 'print encode_base64(123);'
MTIz
[root@hanfangzhou ~]# telnet mail.hanfangzhou.com 25
Trying 192.168.18.48...
Connected to mail.hanfangzhou.com (192.168.18.48).
Escape character is '^]'.
220 mail.hanfangzhou.com ESMTP Postfix
auth login
334 VXNlcm5hbWU6
Y2hhb3l1ZQ==
334 UGFzc3dvcmQ6
MTIz
235 2.0.0 Authentication successful

安裝dovecot服務  yum install dovecot -y

修改配置文件
vim /etc/dovecot.conf
protocols = pop3 pop3s

 protocol pop3 {
     listen = *:10100
#     ..
   }
service dovecot restart    chkconfig dovecot on

安裝cyrus

yum install cyrus-imapd cyrus-imapd-devel -y
修改postfix主配置文件  vim /etc/postfix/main.cf
修改 456行 去掉注釋符 mailbox_transport = lmtp:unix:/var/lib/imap/socket/lmtp
service cyrus-imapd restart  chkconfig cyrus-imapd on
修改cyrus密碼並建立chaoyue用戶郵箱
[root@hanfangzhou ~]# passwd cyrus
Changing password for user cyrus.
New UNIX password:
BAD PASSWORD: it is WAY too short
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
[root@hanfangzhou ~]# cyradm -u cyrus localhost
IMAP Password:
              localhost.localdomain> cm user.chaoyue
localhost.localdomain> cm user.chaoyue.Send
localhost.localdomain> cm user.chaoyue.Trash
localhost.localdomain> cm user.chaoyue.Drafts
安裝 webmail  squirrelmail   yum install squirrelmail -y
設置 wenmail   /usr/share/squirrelmail/config/conf.pl
重啟HTTPD服務
同理設置MAIL服務器2(mail.laohu.com) 
測試

\
Copyright © Windows教程網 All Rights Reserved