Projekt

Allgemein

Profil

Config syslog » Historie » Version 1

Jeremias Keihsler, 13.01.2017 11:27

1 1 Jeremias Keihsler
How to setup a remote syslog server in CentOS 6
2
By jbmurphy on March 23, 2012 in Cisco, Linux 
3
4
I wanted to have a cisco device send it’s logs to a Centos box for troubleshooting. I just wanted to do a “tail -f” against the error logs. Seems that syslog is now rsyslog in Centos 6. To setup rsyslog to accept syslog logs from other devices, you need to:
5
6
1. uncomment out the following lines (not the description lines, the ones that start with “$”)
7
<pre><code class="bash">
8
# Provides UDP syslog reception
9
$ModLoad imudp.so
10
$UDPServerRun 514
11
12
# Provides TCP syslog reception
13
$ModLoad imtcp.so
14
$InputTCPServerRun 514
15
</code></pre>
16
17
2. Add a line or two like these below to say where you want the logs written:
18
<pre><code class="bash">
19
:fromhost-ip,startswith,’192.168.1.’ /var/log/remote.log
20
& ~
21
:fromhost-ip,isequal,”192.168.1.33? /var/log/servername.log
22
& ~
23
</code></pre>
24
25
3. service restart rsyslogd
26
27
4. add a hole in iptables for 514 (UDP and TCP)
28
<pre><code class="bash">
29
-A INPUT -m state –state NEW -m udp -p udp –dport 514 -j ACCEPT
30
-A INPUT -m state –state NEW -m tcp -p tcp –dport 514 -j ACCEPT
31
</code></pre>
32
33
5. service iptables restart
34
35
6. create a new logrotate.d config file in /etc/logrotate.d:
36
<pre><code class="bash">
37
/var/log/remote.log
38
{
39
daily
40
rotate 5
41
missingok
42
notifempty
43
sharedscripts
44
postrotate
45
/bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true
46
endscript
47
}
48
</code></pre>
49
50
Test from a remote machine via
51
<pre><code class="bash">
52
echo '<13> Can you hear me now?' | nc -w 3 -v -u 10.3.120.38 514
53
</code></pre>
54
55
Details on syslog-format
56
[[http://www.dl8rds.de/index.php/Arduino_Syslog_Client_Library]]