CentOS 7:172.20.0.104
Windows 10:172.20.0.102
先設定 DNS Server
主要設定檔 /var/named/chroot/etc/named.conf
zone “vclass.local" { zone “0.20.172.IN-ADDR.ARPA" { |
正解 /var/named/chroot/var/named/vclass.local.zone
$TTL 86400 @ IN NS station.vclass.local. vclass.local. IN MX 10 station.vclass.local. @ IN A 172.20.0.104 |
反解 /var/named/chroot/var/named/172.20.0.zone
$TTL 86400 @ IN NS station.vclass.local. 104.0.20.172.IN-ADDR.ARPA. IN PTR station.vclass.local. |
確認名稱解析都正常
從 Windows 10 解析也都正常
安裝套件 dovecot, postfix
yum install dovecot postfix
修改設定檔
/etc/dovecot/conf.d/10-mail.conf
mail_location = mbox:~/mail:INBOX=/var/mail/%u |
/etc/dovecot/conf.d/10-auth.conf
disable_plaintext_auth = no【禁用純文字認證】 |
/etc/dovecot/dovecot.conf
protocols = pop3 imap【啟動 POP IMAP】 |
/etc/dovecot/conf.d/10-master.conf
service imap-login { |
重新產生 dovecot 憑證
先準備產生憑證的設定檔
/etc/pki/dovecot/dovecot-openssl.cnf
[ req ] [ req_dn ] ST=TAIWAN L=Taipei #O=Dovecot OU=IMAP server CN=mail.vclass.local emailAddress=alice@vclass.local [ cert_type ] |
產生 dovecot 憑證
openssl req -new -x509 -nodes -config /etc/pki/dovecot/dovecot-openssl.cnf -out /etc/pki/dovecot/certs/dovecot.pem -keyout /etc/pki/dovecot/private/dovecot.pem -days 3650
chown root:root /etc/pki/dovecot/certs/dovecot.pem /etc/pki/dovecot/private/dovecot.pem
chmod 0600 /etc/pki/dovecot/certs/dovecot.pem /etc/pki/dovecot/private/dovecot.pem
openssl x509 -subject -fingerprint -noout -in /etc/pki/dovecot/certs/dovecot.pem
啟動 dovecot
systemctl start dovecot
systemctl enable dovecot
再來換成 postfix
/etc/postfix/main.cf
postconf -e “inet_interfaces = all" postconf -e “smtpd_tls_cert_file = /etc/pki/tls/certs/postfix.pem" |
/etc/postfix/master.cf
submission inet n – n – – smtpd |
重新產生 postfix 憑證
先準備產生憑證的設定檔
/etc/pki/tls/postfix-openssl.cnf
[ req ] [ req_dn ] ST=Taiwan L=Taipei #O=Dovecot OU=SMTP server CN=mail.vclass.local emailAddress=alice@vclass.local [ cert_type ] |
產生 postfix 憑證
openssl req -new -x509 -nodes -config /etc/pki/tls/postfix-openssl.cnf -out /etc/pki/tls/certs/postfix.pem -keyout /etc/pki/tls/private/postfix.pem -days 3650
chown root:root /etc/pki/tls/certs/postfix.pem /etc/pki/tls/private/postfix.pem
chmod 0600 /etc/pki/tls/certs/postfix.pem /etc/pki/tls/private/postfix.pem
openssl x509 -subject -fingerprint -noout -in /etc/pki/tls/certs/postfix.pem
重啟服務
systemctl restart postfix
systemctl enable postfix
systemctl start saslauthd
systemctl enable saslauthd
開啟 firewall
firewall-cmd –permanent –add-service=smtp
firewall-cmd –permanent –add-port=587/tcp
firewall-cmd –permanent –add-port=993/tcp
firewall-cmd –permanent –add-port=995/tcp
firewall-cmd –reload
建立測試用的使用者
useradd alice
echo password | passwd alice –stdin
usermod -aG mail alice
useradd bob
echo password | passwd bob –stdin
usermod -aG mail bob &>/dev/null
最後,如果有需要透過 WWW 分享 certificate 的話…
yum -y install httpd
cp /etc/pki/dovecot/certs/dovecot.pem /var/www/html/
chmod 444 /var/www/html/dovecot.pem
systemctl start httpd
systemctl enable httpd
firewall-cmd –permanent –add-service=http
firewall-cmd –reload
先在 Mail Server,使用指令驗證
切換成 alice,以 mutt 登入 imaps
mutt -f imaps://mail.vclass.local
確認登入的帳號為 alice
輸入密碼【password】
成功登入
驗證 postfix
telnet 172.20.0.104 25
打聲招呼
ehlo mail.vclass.local
另外開個視窗,產生 base64 encode
perl -MMIME::Base64 -e ‘print encode_base64(“\000alice\000password“);’
驗證 SMTP Auth
AUTH PLAIN AGFsaWNlAHBhc3N3b3Jk
驗證加密的 SMTP
openssl s_client -starttls smtp -crlf -connect mail.vclass.local:25
Windows 10 內建的郵件
Outlook的設定
最後來安裝 Openwebmail
參考文件:https://openwebmail.org/openwebmail/download/centos/el7/00.README.txt
下載 repo
cd /etc/yum.repos.d/
wget ftp://openwebmail.org/pub/openwebmail/el7/openwebmail-el7.repo
檔案 /etc/yum.repos.d/openwebmail-el7.repo
[openwebmail-el7] |
直接使用 yum 安裝
yum install openwebmail
初始化
openwebmail-tool –init
修復權限的問題
openwebmail-tool –fix
安裝 mod_ssl,走 https 加密連線
yum install mod_ssl
systemctl restart httpd
firewall-cmd –permanent –add-service=https
firewall-cmd –reload
強制進入加密連線,準備的轉址的首頁 /var/www/html/index.html
<html> |
Browser 只需要輸入簡單的網址
自動轉向到 Openwebmail 的加密連線
大功告成!