Saturday, April 26, 2008

Cacti 與 syslog 結合

很早以前有些人會用 syslog-ng 收集所有機器的 syslog 到一台 log server,
這些收集到的 log 可以:
1. 用 swatch 去抓要監控的字串,執行程式或發送警告訊息
2. 用 phpsyslog 將 syslog 顯示在 web,每隔一段時間顯示更新,值班人員就看 web 顯示的訊息。

但這些都有一些缺點
1. swatch 可能對沒學過 linux 的網管有點麻煩
2. phpsyslog 沒辦法設定對訊息的處置,如執行程式或是 email 通知

所以我一直再想,是否能結合兩者優點,既可以收集 syslog 又可以輕鬆自訂規則了。
後來發現 Cacti 原來就有提供一個很有用的 plugin - syslog ,可以達到我想要的方式。
加上本身 Cacti 帳號管理的功能,我就可以讓每個管理者自己去自訂規格了。
下面的文章就寫的很詳細,我就不再重複寫了。
http://www.openmaniak.com/cacti_plugins.php

Joomla 1.5 延伸套件安裝建議

最近開始學 Joomla 1.5 光是研究繁複的套件就花了一些時間。
為了減少網友逐一嘗試的時間,列出一些 Joomla 架站建議安裝的延伸套件。
目前這份清單很少,但如果有已經測試過不錯的就會更新。

1. Attachments for content articles
文章附件,蠻適合公家機關發布一些申請表格。

2. DOCman or Remository
下載文件管理

3. eXtplorer
後台檔案管理 FTP,部分 IE 版本運作不正常,Firefox 沒問題。


聽說有人要做一個後台 Page View分析的套件,希望能趕快推出,相信這是很多站長需要的。

其他請參考官網 Editor's Pick or Most Popular Extensions 都是不錯的選擇

Sunday, April 13, 2008

選擇性灰名單/ selective greylisting

傳統灰名單的作法

1.垃圾郵件發信-> 郵件主機.
2.郵件主機會請他稍後再寄(這個是發生在第一次跟公司寄信)
3.若為一般郵件主機會在稍後寄一次進來,這時主機會記住他的發信地的 IP。
4.若是垃圾郵件主機,為了時效,反倒就會跳過你的主機下一站傳送。
5.對於記憶的郵件主機網址,會保留固定的天數再釋放。

此為傳統灰名單機制,優點是可以有效阻擋 SPAM 大量寄送,
進而減少 SPAM Mail 所消耗頻寬,增加 Mail Server 可靠度。
缺點是讓第一次寄進來的正常信件,可能會延遲寄送半小時到一小時左右。
由於傳統灰名單的缺點。

為了解決傳統灰名單缺點,新的 "選擇性灰名單/selective greylisting" 解決方案產生。
選擇性灰名單則針對以下具有爛發垃圾信主機特性做 Greylist,
Ex "撥接 IP", "無網域名稱(No DNS)", "網域名稱過長"(四個點以上, aaa.bbb.ccc.com.tw) ,
一般具有合法名稱的郵件主機不做 Greylist,不會受到影響。
所以可以達到阻擋廣告信主機的大量寄送,亦不會影響到正常信件的寄送。


以下為作法

1. 先安裝 postgrey

可以參考 CentOS Wiki <>
http://wiki.centos.org/HowTos/postgrey
至於重送秒數,一般是預設是五分鐘,上面文章是建議 60 秒,以不影響正常郵件運作。
但由於我們是用選擇性的 postgrey ,正常的 mail server 不會影響,
只會影響一些奇奇怪怪的 mail server , 所以我自己是稍微增加 設成 120s

選擇性 postgrey 就參考下面這篇
http://www.arschkrebs.de/postfix/postfix_greylisting.shtml

Tuesday, April 01, 2008

MailScanner 原廠最新文件

這是 MailScanner 原廠的文件,主要由 FSL 提供

以下文件並沒有出現在網頁,而是透過 Google 挖出來的,而且是最新版。

MailScanner 手冊
http://www.fsl.com/support/MailScanner-Manual-Version-1.0.5.pdf

MailWatch 手冊
http://www.fsl.com/support/mailwatch-documentation-1.03.pdf

DefenderMX 是 FSL 所推出的產品,文件的說明雖大致於 MailScanner 相同,
但其設定值卻是值得我們所參考的。
http://www.fsl.com/docs/DefenderMX-manual.1.9.pdf

Monday, March 10, 2008

Postfix 疑難百解收集

目前慢慢會把一些 Postfix 遇到的一些問題,放在這裡

  • timed out while receiving the initial server greeting
echo 0 > /proc/sys/net/ipv4/tcp_window_scaling

原因是 If you use postfix running on Linux and If you try to telnet the above host on port 25, the connection is made but the remote mail server doesn't send its 220 message upon connection.
上次遇到這種主機是 Microsoft ESMTP MAIL Service, Version: 6.0

ref http://dbraslavsky.blogspot.com/2007/12/timed-out-while-receiving-initial.html

利用 LFTP 建立 YUM Server

看過很多人用不同的方法來架 YUM Server 各有利弊
在經過一番的選擇後 後來我是選擇使用 LFTP 來架 YUM Server
原因是他的彈性語法簡單易懂 可以搭配 exclude 或 include 來指定要下載的 rpms
例如 openoffice 很少用就可以用 exclude 來排除,
或是 centosplus 你只需要更新 kernel-xxx-centos.plus ,可以 include 只下載需要的部份。

以下是 CentOS 5.X 的範例,為了避免字數過長,將 rpm 放到 /centos 目錄
另外 httpd 的設定,相信大家都會,就不再贅述。

mkdir /centos
cd /centos
wget http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
mkdir -p /centos/5/os/i386

ps. key 要放在 /centos 主目錄,此行亦可以放在 lftp config 裡面

vi centos5-lftp.config
ps. 可以用 -x openoffice 表示不下載 openoffice
以下範例視個人需要,把註解拿掉。若只需要抓一次,建議抓完後註解掉,節省 LFTP 檢查的時間。
寫好後執行

lftp -f centos5-lftp.config

若沒有問題,可以放到 crontab 每星期更新一次就好了 每天更新也沒用
因為 CentOS 更新頻率約一星期一次,而且通常是假日

以下為 centos5-lftp.config 內容
#以下有三個 FTP 站台供選擇
open http://ftp.cs.pu.edu.tw
#open ftp.tcc.edu.tw
#open http://ftp.twaren.net
# only need to get repodata, headers, rpms
#
# For OS, 第一次才需要,抓完後可以註解掉
mirror -e --delete /Linux/CentOS/5/os/i386/repodata /centos/5/os/i386/repodata
mirror -e --delete /Linux/CentOS/5/os/i386/CentOS /centos/5/os/i386/CentOS
#For boot server ,抓完後可以註解掉
mirror -e --delete /Linux/CentOS/5/os/i386/images /centos/5/os/i386/images
mirror -e --delete /Linux/CentOS/5/os/i386/isolinux /centos/5/os/i386/isolinux
#以上四行亦可換成下面一行
#mirror -e --delete /Linux/CentOS/5/os/i386 /centos/5/os/i386
#For update
mirror -e --delete /Linux/CentOS/5/updates/i386/repodata /centos/5/updates/i386/repodata
mirror -e --delete -x openoffice /Linux/CentOS/5/updates/i386/RPMS /centos/5/updates/i386/RPMS
#For extra
#mirror -e --delete /Linux/CentOS/5/extras/i386/repodata /centos/5/extras/i386/repodata
#mirror -e --delete /Linux/CentOS/5/extras/i386/RPMS /centos/5/extrass/i386/RPMS
#For centosplus
mirror -e --delete /Linux/CentOS/5/centosplus/i386/repodata /centos/5/centosplus/i386/repodata
mirror -e --delete /Linux/CentOS/5/centosplus/i386/RPMS /centos/5/centosplus/i386/RPMS


然後就可以將 /etc/yum.repos.d/CentOS-Base.repo
每一行 baseurl 改成你目前的主機 並將 mirrorlist 註解掉
baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
改成 baseurl=http://you.server.com/centos/$releasever/updates/$basearch/

如下。只列出 base, update, exteas, centosplus

[base]
name=CentOS-$releasever - Base
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
baseurl=http://10.254.1.1/pub/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://10.254.1.1/pub/centos/RPM-GPG-KEY-CentOS-5

#released updates
[update]
name=CentOS-$releasever - Updates
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
baseurl=http://10.254.1.1/pub/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://10.254.1.1/pub/centos/RPM-GPG-KEY-CentOS-5

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
baseurl=http://10.254.1.1/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://10.254.1.1/pub/centos/RPM-GPG-KEY-CentOS-5
enabled=0

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
baseurl=http://10.254.1.1/pub/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://10.254.1.1/pub/centos/RPM-GPG-KEY-CentOS-5


如果是 CentOS 4.X ,則要多 mirror 一個 headers 的目錄,簡單的範例如下
cat centos4-ftp.config
#以下有三個 FTP 站台供選擇
open http://ftp.cs.pu.edu.tw
#open ftp.tcc.edu.tw
#open http://ftp.twaren.net
# only need to get repodata, headers, rpms
#
# For OS, 第一次才需要,抓完後可以註解掉
mirror -e --delete /Linux/CentOS/4/os/i386 /centos/4/os/i386
# For Update
mirror -e --delete /Linux/CentOS/4/updates/i386/repodata /centos/4/updates/i386/repodata
mirror -e --delete /Linux/CentOS/4/updates/i386/headers /centos/4/updates/i386/headers
mirror -e --delete -x office /Linux/CentOS/4/updates/i386/RPMS /centos/4/updates/i386/RPMS

SMTP 線上測試網站

一般 Mail Server 架好,如果要測試寄信是否正常,通常我們可以寄一封信到 Gmail , 或是 Yahoo ,看是否可以收到。

不過有時候我們會想要用 telnet 到對方 port 25 來了解 SMTP 對話的過程。由於這些指令並不是每個人都很熟悉,我們還是交給軟體來代勞吧!

下面是我找到一個可以線上測試 SMTP 的網站
http://www.zoneedit.com/smtp.html

測試時會將與 Mail Server 對談的訊息,顯示在網頁,我們就可以很清楚知道 SMTP 對話過程。

Sunday, March 09, 2008

[Ubuntu] deborphan 清除不用的檔案

系統跑一段時間,難免總是會有一些程式沒有正常移除。Ubuntu 有一個小工具程式 deborphan ,可以幫我們來作清理的動作。

安裝 deborphan
sudo apt-get install deborphan

執行 deborphan
sudo deborphan | xargs sudo apt-get -y remove –purge

如果想要圖形版的也有 叫 GTKopphan
網址為http://www.marzocca.net/linux/gtkorphan.html#download

wget http://ftp.debian.org/debian/pool/main/g/gtkorphan/gtkorphan_0.4.3-1_all.deb

dpkg -i gtkorphan_0.4.3-1_all.deb


安裝後,系統就會出現 "Remove Orphaned Packages" 這個工具

這個工具很簡單,就討論到這裡囉

參考文章:
Cleaning up a Ubuntu GNU/Linux system
http://www.ubuntugeek.com/cleaning-up-all-unnecessary-junk-files-in-ubuntu.html

Friday, March 07, 2008

MailScanner 設定 for Postfix 筆記(未完)

0. 基本資訊
%org-name% = yoursite
%org-long-name% = Your Organisation Name Here
%web-site% = www.your-organisation.com

1. report
%report-dir% = /etc/MailScanner/reports/tw

2. MTA 相關設定
Run As User = postfix
Run As Group = postfix
Incoming Queue Dir = /var/spool/postfix/hold
Outgoing Queue Dir = /var/spool/postfix/incoming

3. 掃描附件設定
Maximum Archive Depth = 0

Maximum Archive Depth 附件的壓縮檔深度 , mailout 設定為 0 即不限制以避免困擾

4. 掃毒程式 for sophossavi

Virus Scanners = sophossavi
Still Deliver Silent Viruses = yes
Allowed Sophos Error Messages = "corrupt", "format not supported", "File was encrypted", "The main body of vi
rus data is out of date", "Password protected file"
Sophos IDE Dir = /usr/local/sav
Sophos Lib Dir = /usr/local/lib
Monitors For Sophos Updates = /usr/local/sav/*.ide
Quarantine Whole Message = yes
Quarantine Whole Messages As Queue Files = yes

說明:
Virus Scanners 指定掃毒引擎
Still Deliver Silent Viruses 是否遞送 Silent Viruses
Allowed Sophos Error Messages 是否允許 Sophos 掃描所發生的錯誤訊息,如果發生 Excel 檔案加密 File was encrypted , Sophos 無法掃描,則要設定允許的錯誤訊息才能寄送。

5. SpamAssassin 設定
Sign Clean Messages = no
Spam Score Character = *
SpamScore Number Instead Of Stars = yes

SpamAssassin User State Dir = /var/spool/MailScanner/spamassassin


6. MailWatch 設定
Always Looked Up Last = &MailWatchLogging