Postfix維護與管理技巧

1,快速查出系統有那些值得注意的事情:

#egrep '(reject|warning|error|fatal|panic):' /var/log/maillog
#tail -f /var/log/maillog |grep -e "Pass|LOGIN"
2,檢查main.cf配置文件是否正確:
#postfix check

3,重啓Postfix服務與重新載入配置:
#service postfix restart
#postfix reload

4,一封郵件最多幾位收件人限制,默認1000,修改main.cf
smtpd_recipient_limit = 100

5,單封郵件容量上限,默認10MB,修改main.cf
message_size_limit = 10000000

6,客戶端出錯或惡意錯誤連接可用以下限制main.cf
smtpd_error_sleep_time = 1s
smtpd_soft_error_limit = 10
smtpd_hard_error_limit = 20

7,改變投遞地址,假如用戶[email protected]更換了新地址,使用以下方法提示其它用戶:
(1)在/etc/postifx/main.cf中添加relocated_maps = hash:/etc/postfix/relocated參數
(2)touch /etc/postfix/relocated
在relocated中添加以下信息
[email protected] 
  [email protected]
#postmap /etc/postfix/relocated
#postfix reload

8,網域更換
(1)在/etc/postifx/main.cf中添加relocated_maps = hash:/etc/postfix/relocated參數
(2)touch /etc/postfix/relocated
在relocated中添加以下信息
@23day.com   23day.cn
#postmap /etc/postfix/relocated
#postfix reload

9,郵件隊列管理工具postqueue與postsuper
#postqueue -p查看郵件隊列
如果隊列序號加了*號表示爲活動隊列
如果隊列序號加了!號表示爲延期隊列
如果隊列序號沒有*與!號表示爲等待隊列
#postsuper -d DBA3F1A9刪除隊列裏的郵件
#postsuper -d ALL刪除隊列裏所有的郵件
#postsuper -r ALL重新排隊所有郵件
#postcat -q DBA3F1A9查看郵件內容

10,郵件轉發設置將所有出站郵件轉發到192.168.1.1服務器上main.cf
relayhost = 192.168.1.1

11,針對某個域的轉發
#vi /etc/postfix/main.cf 新增transport_maps = hash:/etc/postfix/transport
#vi /etc/postfix/transport gmail.com  smtp:[192.168.1.10] 設定寄往gmail的郵件從192.168.1.10機器轉發出去
#postmap /etc/postfix/transport
#postfix reload

12,CentOS4.7下掛載共享目錄
#mount -t cifs -o username=extmailuser,password="mis[]229" //172.28.156.122/extmail /mnt

13,配置垃圾郵件策略行爲"D_DISCARD->丟棄,D_PASS->通過,D_BOUNCE->返回"
#vi /etc/amavisd.conf 第115行到118行
$final_virus_destiny      = D_PASS;   
$final_banned_destiny     = D_BOUNCE;
$final_spam_destiny       = D_PASS;
$final_bad_header_destiny = D_PASS;

14,單網卡又IP配置
#cd /etc/sysconfig/network-scripts/
#cp ifcfg-eth0 ifcfg-eth0:0
編輯ifcfg-eth0:0裏的DEVICE參數爲eth0:0
#service network restart

15,CentOS4.7使用代理上網(命令行上網)
編輯/etc/profile文件
#vi /etc/profile
http_proxy=192.168.1.1:3128  代理分別指定http,https,ftp
https_proxy=192.168.1.1:3128
ftp_proxy=192.168.1.1:3128
no_proxy=192.168.1.  局域網不使用代理
export http_proxy https_proxy ftp_proxy no_proxy
保存重啓機器

16,拒絕某一IP發送郵件服務器(方法很多)
#vi /etc/postfix/main.cf
smtpd_client_restrictions =
check_client_access hash:/etc/postfix/client_access
#vi /etc/postfix/client_access
192.168.1.5    REJECT   拒絕192.168.1.5發送郵件

17,使用代理升級CentOS(yum)
#vi /etc/yum.conf
proxy=http://192.168.1.55:3128
proxy_username=yum-user
proxy_password=yum-passwd

18,郵件隊列處理方式4種隊列
收件(incoming),活動(active),延遲(deferred),故障(corrupt)
新郵件第一站是"收件隊列"如果系統資料空閒,會轉到"活動隊列",如果投遞失敗會被移入"延遲隊列"

19,投遞操作
Postfix以收件人地址類型判斷如何投遞郵件,主要地址類型及投遞順序爲本地(local),虛擬別名(Virtual alias),虛擬郵箱(virtual mailbox)以及轉發(relay).

20,clamav殺毒軟件RPM下載地址http://packages.sw.be/clamav/
下載最新版然後使用rpm -Uvh升級.

21,mysql導出查詢結果
mysql>select name,username from mailbox into outfile 'mail.txt' fields terminated by ',';
默認導出文件在/var/lib/mysql/extmail目錄

21,全局通訊錄生成方法
首先使用21項導入數據,然後使用excel編輯保存成csv檔,再將數據複製到globabook.cf中就可以了(官方現有批perl工具,非常好用,這是不知道這工具之前想的辦法)

22,添加靜態路更新freshclam(未驗證是否成功)
61.177.194.0    192.168.1.118  255.255.255.0

23,使用rsync同步home目錄
Server配置:
#vi /etc/xinetd.d/rsync 將disable改爲no
#vi /etc/rsyncd.conf 添加以下內容
[extmail]
path=/home/domains
auth users=admin
uid=root
gid=root
secrets file=/etc/rsyncd.secrets
read only=yes
#vi /etc/rsyncd.secrets 添加以下內容
admin:password
#chmod 600 /etc/rsyncd.secrets
#/etc/xinit.d/xinetd restart
Client配置:
vi /etc/rsyncd.secrets添加密碼"password"
#rsync -vzrtopg --delete --progress [email protected]::extmail /home/domains --password-file=/etc/rsyncd.secretes

24, freshclam使用代理升級病毒庫(其實很簡單,找得好辛苦)
#vi /etc/freshclam.conf 將此配置文件的以下代理設置打開就可以了
HTTPProxyServer 192.168.1.9
HTTPProxyPort 3128

25,改變投遞地址
#vi main.cf
relocated_maps = hash:/etc/postfix/relocated
#vi relocated
[email protected]    [email protected]
#postmap relocated

26,傳輸表(郵件網關可用),使用relay參數將mail.23day.com的郵件直接轉發到192.168.1.9主機上
#vi main.cf
transport_maps = hash:/etc/postfix/transport
#vi transport
mail.23day.com    relay:[192.168.1.9]
#postmap transport
#postfix reload

27,bcc監視用戶郵件main.cf
always_bcc = [email protected]
recipient_bcc_maps = hash:/etc/postfix/recipient_bcc_maps
sender_bcc_maps = hash:/etc/postfix/sender_bcc_maps
#touch /etc/postfix/recipient_bcc_maps
[email protected]  [email protected]
#touch /etc/postfix/sender_bcc_maps
#postmap /etc/postfix/recipient_bcc_maps
#postmap /etc/postfix/sender_bcc_maps

28,查詢與統計用戶發送與接收了多少郵件
a)[email protected]發送了多少郵件進來
egrep [email protected] /var/log/maillog |grep Pass |grep -v 172.28.156 |wc -l
egrep [email protected] /var/log/maillog |grep Pass |grep 172.28.156.90 |wc -l
egrep [email protected] /var/log/maillog |grep Pass |grep -v 172.28.156.90 |wc -l

29,header_checks郵件過濾
將所有發給[email protected]的郵件轉發到[email protected]
/^To:.*chinanpg@126\.com*/ REDIRECT        [email protected]
刪除來源地址爲cn99.com的所有郵件並在日誌顯示deletecn99信息
/^From:.*@*\.cn99\.com/     DISCARD deletecn99
拒絕[email protected]發往本域的郵件,將返回錯誤信息給發送者
/^From:.*twork@21cn\.com/        REJECT  rejectspam
螞蟻感覺這篇文章寫的很好,收藏來自http://blog.sina.com.cn/s/blog_44abafb20100fbns.ht
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章