yum remove rsyslog
yum install epel-release
yum install syslog-ng vim logrotate bzip2
systemctl enable syslog-ng && systemctl start syslog-ng
https://www.linuxjournal.com/content/creating-centralized-syslog-server
https://community.spiceworks.com/topic/2084362-syslog-ng-for-multiple-sources
https://www.rfaircloth.com/tags/syslog-ng/
https://lists.balabit.hu/pipermail/syslog-ng/2014-March/021290.html
http://monitoringartist.github.io/community.zenoss.org/message/48987.html
vim /etc/syslog-ng/conf.d/remote.devices.conf
### Accept connections from tcp/upd source s_network_a {tcp(max-connections(5000)); udp (); }; ### Filters to separate logs by ip/host and a filter to catch all that don't match filter f_bredband_webermotors_local { netmask("10.222.190.229/32"); or host("bredband.webermotors.local"); }; filter f_gw01_nytnetwork_com { netmask("172.18.18.1/32"); or host("gw01.nytnetwork.com"); }; filter f_unknown { not ( netmask("10.222.190.229/32") or netmask("172.18.18.1/32") or host("gw01.nytnetwork.com") ); }; ### Destinations for to keep a local copy and send them on further. Note the SIEM/OSSIM destination has spoof_source(yes) otherwise the SIEM will log it under the syslog servers IP. destination d_ossim { udp("172.18.18.40" spoof_source(yes)); }; destination d_bredband_webermotors_local { file("/var/log/remote/bredband.webermotors.local.log"); }; destination d_gw01_nytnetwork_com { file("/var/log/remote/gw01.nytnetwork.com.log"); }; destination d_unknown { file("/var/log/remote/unknown.log"); }; ### And it all comes together... log { source(s_network_a); filter(f_bredband_webermotors_local); destination(d_bredband_webermotors_local); destination(d_ossim); }; log { source(s_network_a); filter(f_gw01_nytnetwork_com); destination(d_gw01_nytnetwork_com); }; log { source(s_network_a); filter(f_unknown); destination(d_unknown); };
mkdir /var/log/remote
systemctl restart syslog-ng
firewall-cmd --add-port=514/tcp firewall-cmd --add-port=514/udp firewall-cmd --reload
If you need to use non-standard ports or need to troubleshoot or use semanage to make a rule here is an example of what to do:
yum install policycoreutils-python semanage port -a -t syslogd_port_t -p tcp 8100 semanage port -a -t syslogd_port_t -p udp 8100 semanage fcontext -a -t var_log_t /var/splunk-syslog restorecon -v '/var/splunk-syslog' logger -d -P 8100 -n 127.0.0.1 -p 1 "test2" cd /root mkdir selinux cd selinux audit2allow -M syslog-ng-modified -l -i /var/log/audit/audit.log #verify the file does not contain anything no related to syslog vim syslog-ng-modified.te semodule -i syslog-ng-modified.pp
http://danielsokolowski.blogspot.com/2012/09/maximum-logrotate-compression-with-bzip2.html
vim /etc/logrotate.conf
# uncomment this if you want your log files compressed compress # # use bzip2 whith higher compression than gzip compresscmd /bin/bzip2 uncompresscmd /bin/bunzip2 compressoptions -9 compressext .bz2
# rotate log files weekly weekly # keep 75 weeks worth of backlogs rotate 75