作者: reistlin
来源: http://www.reistlin.com/blog/79
更新时间: 2010.12
版权声明: 原创文章.转载请保留作者信息和原文完整.谢绝任何方式的摘要

redhatjuniper.png

[步骤一] 服务器端配置:Redhat Enterprise Linux AS(RHEL)

1,检查 syslogd 系统进程,默认是启动状态,默认参数为:-m 0

reistlin:~# ps aux | grep syslogd
root      2619  0.0  0.0   1728   616 ?        Ss   Nov29   0:18 syslogd -m 0

2,配置 /etc/syslog.conf 文件,定义防火墙日志的 local1(提示:需要与客户端配置对应,0-6 范围,因为 Linux 系统默认使用 7 来保存 boot messages 日志),并且将日志保存到文件:/home/syslog/netscreen.log

reistlin:~# vim /etc/syslog.conf 

# Juniper NetScreen Firewall syslog messages
local1.* /home/syslog/netscreen.log

3,配置 /etc/sysconfig/syslog 文件,启用远程设备传送日志,并且关闭 DNS lookup

reistlin:~# vim /etc/sysconfig/syslog 

# -r enables logging from remote machines
# -x disables DNS lookups on messages recieved with -r
SYSLOGD_OPTIONS="-rx -m 0"

4,配置 /etc/logrotate.conf 文件,配置日志文件管理工具(旧日志文件压缩打包,同时创建新的日志文件:轮替,转储):每天,或者日志文件超过 1G 进行压缩,如果日志文件为空则忽略,同时保留 3 个备份。

# system-specific logs may be also be configured here.
/home/syslog/netscreen.log {
    missingok
    compress
    notifempty
    monthly
    size 1024M
    rotate 3
    postrotate
        /usr/bin/killall -HUP syslogd
    endscript
}

4,重新启动 syslogd 系统进程

reistlin:~# /etc/init.d/syslog restart

Shutting down kernel logger:                               [  OK  ]
Shutting down system logger:                               [  OK  ]
Starting system logger:                                    [  OK  ]
Starting kernel logger:                                    [  OK  ]

5,检查 syslogd 系统进程,进程参数为:-rx -m 0

reistlin:~# ps aux | grep syslogd
root     18079  0.1  0.0   1728   616 ?        Ss   16:34   0:00 syslogd -rx -m 0

6,检查 syslogd 监听端口,默认端口为:UDP 514

reistlin:~# netstat -nlpu

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name   
udp        0      0 0.0.0.0:514                 0.0.0.0:*                               18079/syslogd

[步骤二] 客户端配置:Juniper NetScreen SSG 系列

1,SSH登录,CLI命令行:

set syslog config "10.0.0.1"
set syslog config "10.0.0.1"" facilities local1 local1
set syslog config "10.0.0.1"" log traffic
set syslog src-interface eth0/0

2,命令行说明:

第1行:服务器端 IP 地址为:10.0.0.1,即我们上面配置的 syslog 服务器 IP 地址。
第2行:定义 facilities local1 ,对应 syslog 服务器的 /etc/syslog.conf 配置。
第3行:启用 log 事件日志traffic 流量日志,均转发到 syslog 服务器。
第4行:定义从哪个网络接口(源网络接口)转发日志。

注意,如果 syslog 服务器不在 Juniper NetScreen 的 Trust 区域,比如 Site-to-Site VPN 环境,必须指定:src-interface 源网络接口,否则会无法传送日志!

[步骤三] 测试,监控:

1,日志信息:

reistlin:~# tail -f /home/syslog/netscreen.log

Dec  2 00:00:00 10.0.0.2 REISTLIN-COM: NetScreen device_id=REISTLIN-COM  [Root]system-notification-00257(traffic): start_time="2010-12-01 00:00:00" duration=2 policy_id=1 service=icmp proto=1 src zone=Trust dst zone=Untrust action=Tunnel (XX_To_YY) sent=102 rcvd=102 src=10.0.0.X dst=10.0.0.Y icmp type=8 src-xlated ip=10.0.0.X dst-xlated ip=10.0.0.Y session_id=57515 reason=Close - RESP
Dec  2 00:00:01 10.0.0.2 REISTLIN-COM: NetScreen device_id=REISTLIN-COM  [Root]system-notification-00257(traffic): start_time="2010-12-01 00:00:01" duration=2 policy_id=2 service=icmp proto=1 src zone=Trust dst zone=Untrust action=Tunnel (YY_To_XX) sent=102 rcvd=102 src=10.0.0.Y dst=10.0.0.X icmp type=8 src-xlated ip=10.0.0.Y dst-xlated ip=10.0.0.X session_id=61869 reason=Close - RESP

2,磁盘读写:

reistlin:~# iostat

Linux 2.6.18-164.el5PAE (security1)     12/01/2010

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           0.01    9.18    0.02    0.01    0.00   90.79

Device:            tps   Blk_read/s   Blk_wrtn/s   Blk_read   Blk_wrtn
sda               0.46         0.60         9.48    6543083  104025877
sda1              0.00         0.12         0.00    1367162        100
sda2              0.00         0.04         0.00     464632        216
sda3              0.46         0.43         8.99    4705810   98658216
dm-0              1.56         2.74        11.15   30053003  122350841
dm-1              1.56         2.74        11.13   30058319  122073657
dm-2              2.82         5.48        22.28   60111012  244424498
hdb               0.00         0.48         0.00    5235552          0

标签: redhat, juniper, linux