I have many Cisco / JunOS routers and switches that send logs to my Debian server, which uses rsyslogd
.
How can I configure rsyslogd
to send these router / switch logs to a specific file, based on their source IP address? I do not want to pollute general system logs with these entries.
For instance:
- all routers in Chicago (source ip block: 172.17.25.0/24) to only log to
/var/log/net/chicago.log
. - all routers in Dallas (source ip block 172.17.27.0/24) to only log to
/var/log/net/dallas.log
. - Delete all
APF-3-RCV_UNSUPP_MSG
messages without logging them - Send logs for 172.17.4.4 to a file named
/var/log/net/firewall.log
- Forward firewall logs to 10.14.12.12 using UDP port 514
Finally, these logs should be rotated daily for up to 30 days and compressed.
NOTE: I am answering my own question
rsyslogd
ConfigurationIn
/etc/rsyslogd.conf
Each of the
&~
entries prevents fall-through to the rest of thersyslog.conf
configuration; thus I won't see router syslog entries in/var/log/messages
.Touch all syslog files:
touch /var/log/net/chicago.log
touch /var/log/net/dallas.log
touch /var/log/net/firewall.log
Restart
rsyslogd
with/etc/init.d/rsyslogd restart
Log rotation
In
/etc/logrotate.d/rsyslog
Also, I found this on the rsyslog wiki that could serve as future refernce for someone.
http://www.rsyslog.com/storing-messages-from-a-remote-system-into-a-specific-file/