Emm*_*ory 24
接收日志的主机需要运行一些配置为侦听远程日志的 syslog 守护进程。Ubuntu 中有许多 syslog 实现,但rsyslog通常是推荐的,并且应该默认安装。我无法从您发布的链接中的文档中判断 DD-WRT 是通过 TCP 还是 UDP 发送日志,因此如果您担心减少网络可访问的数量,可能需要进行一些实验才能准确找到正确的设置主机上的端口。
有两种方法可以实现这一点:第一种更简单,但可能需要在系统升级时重新集成。第二个稍微复杂一些,如果作为更新的一部分对 syslog 配置进行了重大更改,则可能会导致令人困惑的结果。我会选择第二个,但您的偏好可能会有所不同。
第一个是编辑/etc/rsyslogd.conf,并#从以下几行中删除首字母:
#$ModLoad imudp #$UDPServerRun 514
或者
#$ModLoad imtcp #$InputTCPServerRun 514
第二个是创建一个新文件,可能命名为local-enable-tcp.confin /etc/rsyslog.d/,内容如下:
# 启用 TCP 系统日志接收 $ModLoad imtcp $InputTCPServerRun 514
如果您想使用单独的文件方法,并且需要 UDP,请更改内容以匹配上面的 UDP 节。具体的文件名并不重要,但建议以“local-”开头,因为此命名空间是为本地管理员配置保留的,并且必须以“.conf”结尾,因为只有这样结尾的文件才会自动包含在rsyslog 配置。
如果您更喜欢使用另一个 syslog 实现,请检查该实现的配置和文档:很可能 syslog 守护程序被配置为默认情况下不侦听网络,但是应该清楚地记录启用这种常见情况的示例配置。
小智 6
另一种选择是使用 syslog-ng,易于使用,到目前为止准备就绪!
sudo apt-get install syslog-ng
Run Code Online (Sandbox Code Playgroud)
安装后,我们在 /etc/syslog-ng/syslog-ng.conf 中有一个 conf 文件 所以,只需使用我们的参数编辑此 .conf 文件,但在此之前,请备份默认配置文件,如果以后有用你想调整一些参数
sudo mv /etc/syslog-ng/syslog-ng.conf /etc/syslog-ng/syslog-ng.conf.bak
Run Code Online (Sandbox Code Playgroud)
现在创建新的配置文件并编辑它!
sudo touch /etc/syslog-ng/syslog-ng.conf
sudo nano /etc/syslog-ng/syslog-ng.conf
Run Code Online (Sandbox Code Playgroud)
因此,只需粘贴此基本配置即可正常工作:
# Listening to incoming UDP Syslog connections
source mysource { udp(); };
#Add the syslog targets:
destination dest { file("/var/log/Cisco$YEAR$MONTH$R_DAY.log"); };
#destination dest_other_server { udp("1.2.3.4" port(514)); };
#Create the filters that will be used to determine what to do with the received syslog message
#filter filter { ( host("2.3.4.5") and level(notice) and match("username=.*@domain\.local" value("MESSAGE") flags("utf8" "ignore-case")) ); };
filter myfilter { ( level(notice) ); };
#And putting it all together:
log { source(mysource); filter(myfilter); destination(dest); };
Run Code Online (Sandbox Code Playgroud)
正如你所看到的那样简单。小心!