Idea
You have a Junior box or equivalent sitting at the heart of your home network and want to use it as a network syslog archiver for all of your machines.
Aim
All Unix machines on your network store their syslog messages locally and also send them to Junior through UDP packets, where they are stored in separate files for each machine.
Solution
install syslog-ng
The default Debian syslog has the capability to log network-based syslog messages coming from other machines on the same subnet (-r option). Unfortunately, syslog cannot be easily configured to store logs separately
for each machine, so everything ends up in the same files, mixing information from all hosts as well as local messages. This can get quite confusing.
Enters syslog-ng: this new generation brings a lot of useful features, among which the capability to do much better filtering on incoming messages and how to store them. The procedure to install it is as follows:
apt-get install syslog-ng
This will install syslog-ng and remove syslog.
For this example I assume we have a machine on the local network called ‘billy’ at address 192.168.1.10. Modify your /etc/syslog-ng/syslog-ng.conf configuration file as follows:
Add a UDP listener by un-commenting udp() in the source list:
source s_all {
# message generated by Syslog-NG
internal();
# standard Linux log source (this is the default place for the syslog()
# function to send logs to)
unix-stream("/dev/log");
# messages from the kernel
file("/proc/kmsg" log_prefix("kernel: "));
# use the following line if you want to receive remote UDP logging messages
# (this is equivalent to the "-r" syslogd flag)
udp();
};
Add another destination for log files generated by billy:
destination df_billy { file("/var/log/billy/messages.log"); };
Add a filter based on IP:
# all messages from billy
filter f_billy { netmask("192.168.1.10/32"); };
There are probably better ways to do filtering than providing a static IP address. Bear with me, I did not want to get any deeper into syslog-ng documentation since this fits the bill.
Add a rule to combine filter and output directory:
# Billy logs
log {
source(s_all);
filter(f_billy);
destination(df_billy);
};
On billy, make sure syslogd is started with option -R x.x.x.x where the latter is the IP address of your syslog archive box.
You should now get messages logged in /var/log/billy/messages.log.
Posted by nicolas314
Posted by nicolas314
Posted by nicolas314