1. Dlink - router modem 的 DDNS / Port Forward
DDNS 就是动态 DNS, 申请后会得到 member.dlinkddns.com
至于 IP, 设置后 router modem 会替你自动更新
Port Forward 就是端口转向, 端口会转向我的虚拟机 192.168.0.100
需转向的端口有
25 / 465 / 587 (SMTP / SMTPS)
110 / 995 (POP3 / POP3S)
143 / 993 (IMAP / IMAPS)
2. Ubuntu - /etc/hostname 和 /etc/hosts
$ gedit /etc/hostname
member.dlinkddns.com
$ gedit /etc/hosts
127.0.0.1 member.dlinkddns.com localhost
改后重启..
3. UFW 防火壁
$ su
$ apt-get install ufw
$ ufw enable
$ ufw allow from 192.168.0.100
# 同时将以上端口打开
$ ufw allow 25/tcp
$ ufw allow 587/tcp
$ ufw allow 110/tcp
$ ufw allow 995/tcp
$ ufw allow 143/tcp
$ ufw allow 993/tcp
# 确定端口是否打开
$ netstat -plnt
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN 4553/master
tcp 0 0 0.0.0.0:993 0.0.0.0:* LISTEN 2655/dovecot
tcp 0 0 0.0.0.0:995 0.0.0.0:* LISTEN 2655/dovecot
tcp 0 0 0.0.0.0:587 0.0.0.0:* LISTEN 4553/master
tcp 0 0 0.0.0.0:110 0.0.0.0:* LISTEN 2655/dovecot
tcp 0 0 0.0.0.0:143 0.0.0.0:* LISTEN 2655/dovecot
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 1165/mysqld
tcp6 0 0 :::443 :::* LISTEN 2204/apache2
tcp6 0 0 :::993 :::* LISTEN 2655/dovecot
tcp6 0 0 :::995 :::* LISTEN 2655/dovecot
tcp6 0 0 :::110 :::* LISTEN 2655/dovecot
tcp6 0 0 :::143 :::* LISTEN 2655/dovecot
tcp6 0 0 :::80 :::* LISTEN 2204/apache2
4. 准备 SSL / TLS 证书
http://jasonmun.blogspot.my/2017/01/https-lets-encrypt.html
/etc/letsencrypt/live/member.dlinkddns.com/fullchain.pem
/etc/letsencrypt/live/member.dlinkddns.com/privkey.pem
5. 安装
$ su
$ apt install postfix postfix-mysql dovecot-core dovecot-imapd dovecot-pop3d dovecot-lmtpd dovecot-mysql mysql-server
没有评论:
发表评论