rpm -qa | grep bind
# bind-9.2.2-21 (Server)
# bind-utils-9.2.2-21 (Client tools)
/etc/named.conf 定義兩個 zone:
zone "ec.com" IN {
type master;
file "named.ec.com";
};
zone "0.168.192.in-addr.arpa" IN {
type master;
file "named.192.168.0";
};
/var/named/named.ec.com(正向解析):
$TTL 86400
@ IN SOA mail.ec.com. root.mail.ec.com. (
1997022700 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
@ IN NS mail.ec.com.
@ IN MX 10 mail.ec.com.
mail IN A 192.168.0.10
/var/named/named.192.168.0(反向解析):
$TTL 86400
@ IN SOA mail.ec.com. root.mail.ec.com. ( ... )
@ IN NS mail.ec.com.
10 IN PTR mail.ec.com.
/etc/rc.d/init.d/named start
netstat -tuln | grep 53 # 確認 53 port 監聽
# Client 端 /etc/resolv.conf 加入:
nameserver 192.168.0.10
# 測試:
host mail.ec.com
host 192.168.0.10
nslookup mail.ec.com
rpm -qa | grep sendmail # sendmail, sendmail-cf
rpm -qa | grep imap # imap, php-imap
rpm -q mailx # mailx
/etc/mail/sendmail.mc:刪除 DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA') 限制,允許外部連線。
cd /etc/mail
m4 sendmail.mc > sendmail.cf # 重新生成配置
/etc/rc.d/init.d/sendmail start
# POP3
vi /etc/xinetd.d/ipop3 # disable = no
# IMAP
vi /etc/xinetd.d/imap # disable = no
/etc/rc.d/init.d/xinetd restart
netstat -tl # 驗證 smtp(25), pop3(110), imap(143) 監聽
vi /etc/mail/local-host-names
mail.ec.com
vi /etc/aliases
# 群發別名
pm: pm1,pm2,pm3
# 執行更新
newaliases
/etc/mail/access 可設定 relay 限制或拒絕特定 IP,內部純內網環境可暫不調整。
本文聚焦 DNS + Sendmail 基礎建設。OpenWebMail 需額外安裝 Perl 模組、配置 CGI 執行權限、設定網頁伺服器 (Apache) 虛擬主機、整合 PAM 認證等步驟,建議參考官方安裝文件完成後續整合。
| 功能 | 檔案路徑 |
|---|---|
| DNS 主配置 | /etc/named.conf |
| 正向區域檔 | /var/named/named.ec.com |
| 反向區域檔 | /var/named/named.192.168.0 |
| Client DNS | /etc/resolv.conf |
| Sendmail 宏配置 | /etc/mail/sendmail.mc |
| Sendmail 編譯配置 | /etc/mail/sendmail.cf |
| 本地主機名 | /etc/mail/local-host-names |
| 郵件別名 | /etc/aliases |
| POP3/IMAP 啟動 | /etc/xinetd.d/ipop3, imap |