http://www.voidcn.com/article/p-aojtyuii-btx.html
linux – syslog ip使用`rsyslog`到特定文件
如何配置rsyslogd根据源IP地址将这些路由器/交换机日志发送到特定文件?我不想用这些条目污染一般系统日志.
例如:
>芝加哥的所有路由器(源IP块:172.17.25.0/24)只能登录到/var/log/net/chicago.log.
>达拉斯的所有路由器(源ip块172.17.27.0/24)只能登录到/var/log/net/dallas.log.
>删除所有APF-3-RCV_UNSUPP_MSG消息而不记录它们
>将172.17.4.4的日志发送到名为/var/log/net/firewall.log的文件
>使用UDP端口514将防火墙日志转发到10.14.12.12
最后,这些日志应每天轮换最多30天并进行压缩.
在/etc/rsyslogd.conf中
# provides remote UDP syslog reception $ModLoad imudp $UDPServerRun 514 # If logging to an NFS mount, use these settings... # "OMFileFlushOnTXEnd off" avoids fsync on every write... # mount -o hard,rsize=32768,wsize=32768,noacl,noatime,nodiratime -t nfs $OMFileIOBufferSize 768k $OMFileAsyncWriting on $OMFileFlushOnTXEnd off $OMFileFlushInterval 10 $MainMsgQueueSize 100000 # kill all INTF-FLAP messages... if $msg contains 'INTF-FLAP' then /dev/null &~ ## Cisco ACS Accounting... if ($fromhost-ip=='172.17.16.20') and ($programname == 'CSCOacs_TACACS_Accounting') then /var/log/tacacs_acct.log &~ ## CiscoACS 5.4 TACACS Authentication if ($fromhost-ip=='172.17.16.20') and ($programname == 'CSCOacs_Passed_Authentications') then /var/log/tacacs_auth.log &~ # Logging for Chicago issues... if $fromhost-ip startswith '172.17.25' then /var/log/net/chicago.log & ~ # Logging for Dallas issues... if $fromhost-ip startswith '172.17.27' then /var/log/net/dallas.log & ~ # Logging for firewall... if $fromhost-ip=='172.17.4.4' then @10.14.12.12 if $fromhost-ip=='172.17.4.4' then /var/log/net/firewall.log & ~
每个&〜条目都可以防止落入rsyslog.conf配置的其余部分;因此我不会在/ var / log / messages中看到路由器syslog条目.
触摸所有syslog文件:
>触摸/var/log/net/chicago.log
>触摸/var/log/net/dallas.log
>触摸/var/log/net/firewall.log
使用/etc/init.d/rsyslogd restart重新启动rsyslogd
记录旋转
在/etc/logrotate.d/rsyslog中
/var/log/net/*.log { copytruncate rotate 30 daily missingok dateext notifempty delaycompress create root 664 root root compress maxage 31 sharedscripts lastaction # RHEL: Use "/sbin/service rsyslog restart" # Debian / Ubuntu: Use "invoke-rc.d rsyslog reload > /dev/null" invoke-rc.d rsyslog reload > /dev/null endscript }
3. rsyslog使用
4. Rsyslog使用
7. 远程服务器?" style="color: rgb(51, 51, 51); text-decoration-line: none; transition: all 0.25s ease 0s; outline: none 0px;">log-files – 如何使用rsyslog将特定日志文件转发到/ var / log之外的远程服务器?
8. linux syslog
本文链接:https://www.kinber.cn/post/1369.html 转载需授权!
推荐本站淘宝优惠价购买喜欢的宝贝: