南方Linux论坛   首页 | 行业 | 下载 | Blog | 桌面应用 | 数据库 | 电子商务 | 文摘 | 网络服务 | 开源 | 系统管理 | 内核代码 | 教程

返回   南方Linux论坛 > Linux发行版分类讨论区 > Debian专题
注册账号 Blog 论坛帮助 会员列表 日历事件 搜索 今日新帖 标记讨论区已读

发表新主题 回复
 
主题工具 显示模式
旧 2006-12-28, 06:09 PM   #1
xuejin38 帅哥
级别:1 | 在线时长:9小时 | 升级还需:3小时
普通会员
 
注册日期: 2006-12-28
帖子: 52
精华: 0
现金: 242 金币
资产: 242 金币
声望: 10 xuejin38 正向着好的方向发展
默认 Postfix安裝手冊

1. Postfix 安裝手冊

什麼是 Postfix

Postfix 是由 Wietse Venema's (http://www.porcupine.org/wietse/) 開發用來替代使用最廣的 Sendmail 程式;此外,Postfix 試圖在使用上更快速、簡單管理及安全,同時與 sendmail 保持足夠的相容性而不打擾系統中已存在的使用者。尤其近來 Sendmail 經常被發現 local root 的攻擊漏洞加上 Sendmail 發展已久,在安裝及設定上並不是那麼簡單,所以有許多單位或網管人員逐漸改採 Postfix 來做為郵件轉遞的代理者(MTA,Mail Transfer Agent)

2. 建置一個完善的郵件伺服器

Postfix+Pop3+Smtp

由於安裝郵件伺服器必須支援POP3+SMTP 這兩個協定所以必須要安裝Imap(POP3),要啟動Imap必須先具備Xinetd,如果已經安裝了那可以跳過Xinetd的安裝步驟,並接者安裝cyrus-sasl(SMTP)最後開始設定Postfix 就可以完成整個安裝與設定的步驟由於本篇文章只指導安裝所需之步驟,如有其他概念性的問題請參考其他網站所作之介紹,本篇就不再多說

3. 安裝 Xinetd

當我們安裝好 Xinetd 之後千萬要記得把它加入到開機的啟動程序當中

原始碼3.1: 安裝 Xinetd
# emerge xinetd
# rc-update add xinetd default



4. 安裝 uw-imap

當我們安裝好 Imap 的時候預設值是不會啟動各種協定的包括 POP3,所以我們必須去手動修改設定值讓他能夠自動開啟 POP3 協定

原始碼4.1: 安裝並設定 imap
# emerge uw-imap
# nano -w /etc/xinetd.d/ipop3
# default: off
# $Header: /home/cvsroot/gentoo-x86/net-mail/uw-imap/files/uw-ipop3.xinetd,v 1.
# description: The POP3 service allows remote users to access their mail \
# using an POP3 client such as Netscape Communicator, mutt, \
# or fetchmail.
service pop-3
{
socket_type = stream
wait = no
user = root
server = /usr/sbin/ipop3d
log_on_success += USERID
log_on_failure += USERID
disable = yes 修改為NO
}
# /etc/init.d/xinetd restart



5. 安裝 cyrus-sasl

原始碼5.1: 安裝設定 Cyrus-sasl
# emerge cyrus-sasl
# nano -w /etc/sasl2/smtpd.conf
pwcheck_method:saslauthd
我們使用 saslauthd 這個 daemon 來進行認證的工作
# rc-update add saslauthd default
將 saslauthd 加入預設的啟動程序當中



6. 安裝 Postfix

接者我們可以安裝 Postfix 了,不過要注意 USE FLAG 參數部份要先加入 sasl 以及 Mbox 或者 Maildir

原始碼6.1: 安裝設定 Postfix
# nano -w /etc/make.conf
USE=" " 參數當中至少要有 sasl mbox 或者 maildir
mbox 跟 maildir 是郵件儲存格式 這兩種最大的不同是
Maildir 是單封郵件儲存成為一個獨立的檔案
Mbox 是所有郵件儲存成為一個檔案
所以我們不能在 USE 參數當中同時出現這兩個參數,就是這個道理
(依照使用者習慣選擇適當的格式)
# emerge postfix
# nano -w /etc/postfix/main.cf
然後編輯 Postfix的設定檔案
alias_database = hash:/etc/mail/aliases
alias_maps = hash:/etc/mail/aliases
command_directory = /usr/sbin
config_directory = /etc/postfix
daemon_directory = /usr/lib/postfix
debug_peer_level = 2
default_destination_concurrency_limit = 2
inet_interfaces = all
local_destination_concurrency_limit = 2
mail_owner = postfix
mail_spool_directory = /var/spool/mail
設定信箱存取路徑
mailbox_size_limit = 52428800
信箱大小筆者這邊設定50MB
mailq_path = /usr/bin/mailq
manpage_directory = /usr/share/man
message_size_limit = 10485760
單封郵件限制筆者這邊設定10MB
mydestination = $myhostname, localhost.$mydomain $mydomain
接收者的網域或者主機名稱
mydomain = focuses.org
設定網域名稱
myhostname = mail.focuses.org
設定 MAIL 主機名稱,這邊必須與 BIND 所設定的 MX 名稱互相對應
mynetworks_style = subnet
myorigin = $myhostname
newaliases_path = /usr/bin/newaliases
queue_directory = /var/spool/postfix
readme_directory = /usr/share/doc/postfix-2.0.16-r1/readme
relay_domains = focuses.org
接受 Relay 的網域主機
sample_directory = /usr/share/doc/postfix-2.0.16-r1/sample
sendmail_path = /usr/sbin/sendmail
setgid_group = postdrop
unknown_local_recipient_reject_code = 450
smtpd_client_restrictions = permit_sasl_authenticated
Client 端的限制規則 限制未經信任的 Client 登入就要啟動 sasl
機制
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
SMTPD 收件的限制規則
permit_mynetworks:在 mynetworks 這個項目設定的網域 IP 都可以被允許收信
permit_authenticated:允許使用者經過 SASL 的認證方式寄信
reject_unauth_destination:測試過後的主機可以進行 relay ,跟上面設定的
relay_domains 有關連
告訴 SMTP 客戶,該 SMTP 服務器需要進行用戶認證
smtpd_sasl_local_domain =
確認已經經過認證的網域,目前預設是上述設定之 $myhostname
不需要經過認證
smtpd_sasl_security_options = noanonymous
控制本地SMTP認證所採用的機制,這裡是取消匿名認證方法。
存檔離開
# /etc/init.d/postfix restart



7. 測試除錯

原始碼7.1: 測試是否有啟動 SASL 認證機制
# telnet localhost 25
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 mail.focuses.org ESMTP Postfix
ehlo localhost 確認主機狀態
250-mail.focuses.org
250-PIPELINING
250-SIZE 10485760
250-VRFY
250-ETRN
250-AUTH CRAM-MD5 DIGEST-MD5 LOGIN PLAIN NTLM
看到這行代表已經啟動 SASL 認證
250-XVERP
250 8BITMIME
quit 輸入這行離開
221 Bye
Connection closed by foreign host.


原始碼7.2: 除錯
# nano -w /var/log/messages檢查 LOG 檔錯誤訊息

範例一
postfix/local[508]: fatal: open database /etc/mail/aliases.db: No such file or directory
這很明顯代表找不到 aliaases.db
# newaliases
建立 aliaases.db 如果沒有建立的話將無法正常使用
Postfix 這點請大家要注意

範例二
warning: smtpd_sasl_auth_enable is true, but SASL support is not compiled in
這代表當初在安裝 Postfix 的時候 Sasl 機制並沒有被編入其中
所以我們必須要把 Sasl 機制加入到 Postfix 當中
# USE="sasl" emrege postfix 將 Sasl 機制加入到 Postfix

範例三
安裝 Postfix 的時候可能出現的問題
# emerge postfix
Calculating dependencies ...done!

!!! Error: the virtual/mta package conflicts with another package.
!!! both can't be installed on the same system together.
!!! Please use 'emerge --pretend' to determine blockers.
假如出現上述的訊息代表您系統已經安裝了其他的 MTA 軟體
這時候可能要先找出來你所安裝的 MTA 將其移除才能繼續安裝 Postfix 方法如下

# qpkg -I -v smtp
net-mail/ssmtp-2.48 *
# emerge -C ssmtp-2.48
xuejin38 当前离线  
回复时引用此帖
发表新主题 回复


当前查看此主题的会员: 1 (0 位会员和 1 位游客)
 
主题工具
显示模式

发帖规则
不可以发表新主题
不可以回复主题
不可以上传附件
不可以编辑您的帖子

论坛启用 BB 代码
论坛启用 表情符号
论坛启用 [IMG] 代码
论坛禁用 HTML 代码


所有时间均为北京时间。现在的时间是 02:40 AM


vBulletin 3.6.8 Powered by 南方Linux联盟
版权所有 ©2004 - 2009, bbs.linuxunion.net