自從聽到學校要導入 ISMS,其中有一小部份就是要做 Log 的收集 ( 請人來稽核時需收集三個月以上的 Log ),至於要收集哪些 Log 呢?原則上是看單位自行定義,例如我要收集登入成功與否的 Log 或是 Mailserver 的 Maillog ... 前幾天在潛艦那看到這篇將所有機器的 syslog 集中到 syslog server 統一管理,大概測試了一下後是沒有問題。但如果說今天我想要收集不同台 Server 的 Log ,又希望能夠各自存放在自己的目錄該怎麼辦?
假設我的 Log Server 是 FreeBSD 6.2 ,想要收集二台 FreeBSD 的 Log,分別為 FreeBSD 4.11 authlog 及 FreeBSD 6.2 maillog,如下圖所示

首先,我們先來去設定 Client 二台機器,先設定 bbs.bojack.com.tw 這一台電腦 ( 另一台 testbsd.bojack.com.tw 也是一樣 ),去編輯 /etc/syslog.conf 這個檔案,找到這一行
# uncomment this to enable logging to a remote loghost named loghost
在下面加入此行設定,@ 後面的 IP 就是 Syslog Server IP
*.* @10.1.36.52
Client 端設定好之後,接下來再設定 Server 端。首先編輯 /etc/hosts 這檔案,以我這例子來說,我加入了二行。
10.1.36.54 testbsd testbsd.bojack.com.tw
10.1.17.15 bbs bbs.bojack.com.tw
接下來要設定 /etc/rc.conf ,加入這一行
syslogd_flags="-a 10.0.0.0/8:514"
最後要設定 /etc/syslog.conf,這邊需要注意一下。我直接把所有設定檔 PO 出來 ~ 特別注意紅色文字的設定
# $FreeBSD: src/etc/syslog.conf,v 1.28 2005/03/12 12:31:16 glebius Exp $
#
# Spaces ARE valid field separators in this file. However,
# other *nix-like systems still insist on using tabs as field
# separators. If you are sharing this file between systems, you
# may want to use only tabs as field separators here.
# Consult the syslog.conf(5) manpage.
+testbsd
mail.info /var/log/testbsd/maillog
+bbs
auth.info /var/log/bbs/bbsauthlog
*.err;kern.warning;auth.notice;mail.crit /dev/console
*.notice;authpriv.none;kern.debug;lpr.info;mail.crit;news.err /var/log/messages
security.* /var/log/security
local.auth.info;local.authpriv.info /var/log/auth.log
local.mail.info /var/log/maillog
lpr.info /var/log/lpd-errs
ftp.info /var/log/xferlog
cron.* /var/log/cron
*.=debug /var/log/debug.log
*.emerg *
# uncomment this to log all writes to /dev/console to /var/log/console.log
#console.info /var/log/console.log
# uncomment this to enable logging of all log messages to /var/log/all.log
# touch /var/log/all.log and chmod it to mode 600 before it will work
#*.* /var/log/all.log
# uncomment this to enable logging to a remote loghost named loghost
#*.* @loghost
# uncomment these if you're running inn
# news.crit /var/log/news/news.crit
# news.err /var/log/news/news.err
# news.notice /var/log/news/news.notice
!startslip
*.* /var/log/slip.log
!ppp
*.* /var/log/ppp.log
前面四行應該很容易看得懂,至於下面的設定為何要加入 local 呢?因為若不加入 local ,會將其它台的 log 與本機相同 log 名稱混在一起,因此我特別在前面加入了 local !
設定好了之後,請分別重新啟動 syslog 這個服務或是重開機皆可 ~
[1] 潛艦 - 將所有機器的 syslog 集中到 syslog server 統一管理
[2] BSD Help - creating a syslog server
[3] BSD Help - Remote syslog question router to freebsd
[4] 酷學園 - 請問在FreeBSD 上如何設定成為Syslog Client?
[5] 酷學園 - 問freebsd syslogd remote logging 的設定