For some time now I’ve wanted to centralize my Linux Logs. I’ve been stymied by the fact that a) there is something odd about Red Hat’s default Syslog package and b) I’m too stubborn to add a custom package (like syslog-ng) for the task.
Fortunately, the combination of a post to the Syslog user forums and patience and good fortune have led to a solution.
- On the server, edit /etc/sysconfig/syslog and add -r to the SYSLOGD_OPTIONS to enable the server to accept remote logging on UDP 514.
- Add *.* @server.address to the /etc/syslog.conf file on the client. For Red Hat systems the server address should be indicated as 0.0.0.0 instead of 127.0.0.1 as you would for other Linux distributions.
- Set up a process on the server that uses netcat to reroute incoming TCP traffic on some high, arbitrary port to UDP 514. For example, nc -l -p 9999 | nc localhost -u syslog.
- Set up a process on the client that uses netcat to reroute the outgoing UDP syslog traffic to some high, arbitrary port. For example, nc -l -u -p syslog | nc localhost 9999.
- Set up an SSH tunnel between the two machines that captures the traffic from port 9999 on the client and sends it to port 9999 on the server.
- Watch your centralized Syslog entries fill up.