感謝CCTV,感謝MTV,感謝高主任幫我寫的腳本。
原文刊載於高主任cu論壇-http://blog.chinaunix.net/uid-25256412-id-4228235.html
1>: 安裝配置postfix
# apt-get install postfix (安裝postfix) 或: # aptitude install postfix # echo 'www.yes4ko.com' >/etc/hostname (修改主機名) # echo 'X.X.X.X www.yes4ko.com www' >> /etc/hosts # echo 'X.X.X.X ftp.yes4ko.com ftp' >> /etc/hosts # vim /etc/postfix/main.cf myhostname = www.yes4ko.com (主機名FQDN) alias_maps = hash:/etc/aliases alias_database = hash:/etc/aliases myorigin = yes4ko.com (發件人地址) mydestination = www.yes4ko.com, localhost.localdomain (允許收件的主機) relayhost = (由於是非公網domain,需要由上游ISP MTA幫忙送信,置空即可!) mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 hash:/etc/postfix/access (只允許這些地址使用postfix) mailbox_size_limit = 0 recipient_delimiter = + inet_interfaces = all inet_protocols = ipv4 relay_domains = yes4ko.com, localhost :wq # vim /etc/postfix/access .yes4ko.com OK (允許此domain使用postfix) X.X.X. REJECT (拒絕X.X.X.0/24使用postfix) :wq # postalias hash:/etc/aliases (重新生成) # postmap hash:/etc/postfix/access # /etc/init.d/postfix reload (重新加載配置文件) # /etc/init.d/postfix check (檢查 postfix 相關的配置文件) # /etc/init.d/postfix start (運行 postfix 服務) # /etc/init.d/postfix stop (停止 postfix 服務) # /usr/sbin/postqueue -p (查看郵件隊列排隊的郵件) 或: # mailq # /etc/init.d/postfix flush (強制將目前正在郵件隊列排隊的郵件寄出)
2>: 自動獲取公網地址
# vim /usr/sbin/getPubIP.sh (編寫腳本取得公網IP並mail至相關郵箱) #!/bin/sh #Program: save as /usr/sbin/getPubIP.sh # DATE=$(date +'%Y-%m-%d %H:%M:%S') curl ifconfig.me/ip > getip.txt 2>&1 echo $DATE >> getip.txt tail -2 getip.txt| mail -s 'Today's Public IP Addr' [email protected] :wq
3>: 配置 routine
# echo '07 */1 * * * root /usr/sbin/getPubIP.sh' >> /etc/crontab (每間隔1小時執行一次該腳本)
4>: Reserved for future use....
5>: Reserved for future use....
6>: Reserved for future use....
7>: Reserved for future use....
More About Debian : http://bbs.chinaunix.net/thread-3751791-1-1.html
More About Postfix: http://www.postfix.org/STANDARD_CONFIGURATION_README.html#null_client