Cấu hình log tập trung cho DNS chạy Bind trên Centos 7, sử dụng syslog-ng
IP DNS Server: 192.168.206.140
IP Window: 192.168.206.1, dùng giả lập làm Syslog server
2 máy này có thể ping thông nhau.
Phần 1: Cài Syslog-ng
#yum install epel-release
#yum list *syslog-ng*
#yum install *syslog-ng*
Disable rsyslog
#systemctl stop rsyslog
#systemctl disable rsyslog
Phần 2: Cấu hình log truy vấn của Bind bắn ra daemon
logging {
channel log_query {
file "log_query" versions 3 size 100m;
severity info;
print-category yes;
print-severity yes;
print-time yes;
};
channel log_query_syslog {
syslog daemon;
severity info;
print-category yes;
print-severity yes;
print-time yes;
};
channel default_debug {
file "named.run";
severity dynamic;
};
category "queries" { "log_query"; "log_query_syslog"; };
category "default" { "default_debug"; };
category "security" { "default_debug"; };
category "config" { "default_debug"; };
category "notify" { "default_debug"; };
category "lame-servers" { "default_debug"; };
};
Phần 3: Dựng syslog server giả lập:
Trên máy tính window có ip 192.168.206.1 , cài phần mềm syslog server miễn phí.
Các thiết lập trong setup để mặc định.
Phần 4: Cấu hình syslog-ng để đón log từ daemon và đẩy lên syslog server qua UDP 514
[root@DNS02 log]# more /etc/syslog-ng/syslog-ng.conf
@version:3.5
@include "scl.conf"
# syslog-ng configuration file.
#
# This should behave pretty much like the original syslog on RedHat. But
# it could be configured a lot smarter.
#
# See syslog-ng(8) and syslog-ng.conf(5) for more information.
#
# Note: it also sources additional configuration files (*.conf)
# located in /etc/syslog-ng/conf.d/
options {
flush_lines (0);
time_reopen (10);
log_fifo_size (1000);
chain_hostnames (off);
use_dns (no);
use_fqdn (no);
create_dirs (no);
keep_hostname (yes);
};
source s_sys {
system();
internal();
# udp(ip(0.0.0.0) port(514));
};
destination d_cons { file("/dev/console"); };
destination d_mesg { file("/var/log/messages"); };
destination d_auth { file("/var/log/secure"); };
destination d_mail { file("/var/log/maillog" flush_lines(10)); };
destination d_spol { file("/var/log/spooler"); };
destination d_boot { file("/var/log/boot.log"); };
destination d_cron { file("/var/log/cron"); };
destination d_kern { file("/var/log/kern"); };
#destination d_daemon { file("/var/log/log_query"); };
destination d_daemon {udp("192.168.206.1" port (514)); };
destination d_mlal { usertty("*"); };
filter f_kernel { facility(kern); };
filter f_daemon { facility(daemon) and level(info); };
filter f_default { level(info..emerg) and
not (facility(mail)
or facility(authpriv)
or facility(cron)); };
filter f_auth { facility(authpriv); };
filter f_mail { facility(mail); };
filter f_emergency { level(emerg); };
filter f_news { facility(uucp) or
(facility(news)
and level(crit..emerg)); };
filter f_boot { facility(local7); };
filter f_cron { facility(cron); };
#log { source(s_sys); filter(f_kernel); destination(d_cons); };
log { source(s_sys); filter(f_kernel); destination(d_kern); };
log { source(s_sys); filter(f_default); destination(d_mesg); };
log { source(s_sys); filter(f_auth); destination(d_auth); };
log { source(s_sys); filter(f_mail); destination(d_mail); };
log { source(s_sys); filter(f_emergency); destination(d_mlal); };
log { source(s_sys); filter(f_news); destination(d_spol); };
log { source(s_sys); filter(f_boot); destination(d_boot); };
log { source(s_sys); filter(f_cron); destination(d_cron); };
log { source(s_sys); filter(f_daemon); destination(d_daemon); };
# Source additional configuration files (.conf extension only)
@include "/etc/syslog-ng/conf.d/*.conf"
# vim:ft=syslog-ng:ai:si:ts=4:sw=4:et:
[root@DNS02 log]#
Phần 5: Kiểm tra
Khởi động syslog-ng và cho syslog-ng khởi động cùng HĐH
#systemctl start syslog-ng
#systemctl enable syslog-ng
Khởi động DNS:
#/usr/local/sbin/named -c /etc/named.conf
Kiểm tra:
Mở 2 cửa sổ, 1 cửa sổ là phần mềm Visula Syslog server
1 cửa sổ để truy vấn máy chủ DNS.
Kết quả khi truy vấn DNS, thì trên Syslog server xuất hiện thông tin log là thành công.
Nguồn tài liệu: http://books.pro.vn
Đón xem các clip chi tiết tại kênh: http://youtube.com/huybacnguyen
Nếu bạn thấy hữu ích, vui lòng like, share và subscribes kênh của mình