Softpedia
 

NEWS CATEGORIES:



NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
Home > News > Linux > Other Tips, Tricks and Tutorials

January 10th, 2007, 09:09 GMT · By Mihai Marinof

Setting Up A Central Syslog Server

SHARE:

Adjust text size:


One of the things I like most about Linux is that everything going on inside it is being logged. Whether a user logs in through ssh or a new visitor is passing through your website, everything is being logged in detail. However, the events related to the system are logged by a tool called syslog, which should be present on all Linux systems. Unfortunately, if a hacker breaks into your system, the first thing he'll probably try to do is cover all traceable tracks, rendering the logging tool useless. Basically, if the hacker is any good, you won't find any incriminating traces through the log files. You might even have a backdoor installed and not know anything about it. But this is where the syslog's remote reception feature comes in handy. You can set a syslog server on a safe, unused computer that will act as a central logging system for other computers (public computers that are more likely to be targeted) from the local network or even Internet. This way, all computers will immediately send any system-related events to the syslog server, ensuring that your logs will be completely accurate and un-tampered with at all times.

This article will describe in detail how to set up a syslog server for one or more Unix systems, on Fedora Core and Ubuntu/Debian. However, it *should* work for just about any Linux distribution.


Configure the syslog SERVER

I'm sure most, if not all, Linux systems already have syslog installed so I'll skip this step.

- First of all, you'll need to stop the syslog service:

Fedora Core:
CODE
service syslog stop

Ubuntu/Debian
CODE
/etc/init.d/sysklogd stop

If you're running another distribution and these steps fail, also try:
CODE
/etc/rc.d/rc.syslog stop
and if it fails again, go for the old-school kill command:
CODE
ps axfu | grep syslog
copy the PID (number from second column) from the syslog line and:
CODE
kill -9 PID

Example:
CODE
root:core][~]# ps axfu | grep syslog
root 12699 0.0 0.1 3884 668 pts/0 S+ 10:16 0:00 _ grep syslog
root 12688 0.0 0.1 1692 576 ? Ss 10:12 0:00 syslogd -rm 0
[root:core][~]# kill -9 12688

- Next, you'll have to either edit the syslog start-up script to start syslog daemon with the "-r" flag, or manually start it with that flag. "-r" will enable remote reception feature, which will allow incoming logs.

Fedora Core:
- Open /etc/sysconfig/syslog with your favorite text editor
- Find the line:
CODE
SYSLOGD_OPTIONS="-m 0"
- Replace it with:
CODE
SYSLOGD_OPTIONS="-rm 0"
- Restart the syslog daemon:
CODE
service syslog restart

Ubuntu/Debian:
- Open /etc/init.d/sysklogd with your favorite text editor
- Find the line:
CODE
SYSLOGD="-u syslog"
- Replace it with:
CODE
SYSLOGD="-ru syslog"
- Restart the syslog daemon:
CODE
/etc/init.d/sysklogd restart

On BOTH distributions you should see a message similar to "syslog restarted (remote reception) when executing the command:
CODE
tail /var/log/messages

On other distributions you should either find the RC syslog file, edit it and add the "-r" flag to the syslog options or, if you've used the old-school kill command, simply start syslog manually:
CODE
syslogd -r

- In the final step, you'll have to make sure the firewall isn't blocking any incoming packets. Simply run this iptables command so any rule will be overridden:
CODE
iptables -I INPUT -p udp -i eth0 -s 192.168.1.2 -d 192.168.1.1 --dport 514 -j ACCEPT

This rule will ensure that the syslog server (192.168.1.1) will receive UDP packets (containing log events) from the CLIENT (192.168.1.2). You MUST replace these IP addresses with the correct ones. Also, you will have to re-execute this command for every other client PC you may have (192.168.1.3, 192.168.1.4 etc).

Then add this line (or lines) to rc.local so it will be executed every time the system boots.


Configure the CLIENT computers

- The client computers are configured to send any logged event to the syslog server, immediately as the events occur. To do this, edit the file /etc/syslog.conf on every client computer and add this line AT THE TOP of the file:
CODE
*.* @192.168.1.1

Again, replace the example IP address with the syslog server's correct IP address.

- Next, restart the syslog on every client you've edited:
CODE
service syslog restart
# or
/etc/init.d/sysklogd
# or
/etc/rc.d/rc.syslog restart
# or
ps axfu | grep syslog
kill -9 PID
syslogd

- Finally, make sure the client machine is allowed by the firewall to send UDP packets. Again, you can easily override any rule by running the iptables command:
CODE
iptables -I OUTPUT -p udp -i eth0 -s 192.168.1.2 -d 192.168.1.1 --dport 514 -j ACCEPT
Also, add this line to rc.local so it will be executed on every system boot.

This is it. If everything was done correctly, you should start receiving log events to the syslog server. To view them, run:
CODE
tail -f /var/log/messages
(CTRL + C to escape)
tail -f /var/log/secure
(CTRL + C to escape)

KEEP IN MIND that the machine running the central syslog MUST be secured to the fullest extent. If possible, use a machine that doesn't do much on your network so it won't capture attacker's attention, otherwise the whole purpose will be defeated.

TELL US WHAT YOU THINK:

118,222 hits · 7 comments · Link to this article · Print article · Send to friend · Subscribe to news

MUST-READ RELATED ARTICLES:


Creating a Local Update Repository for FC6

Local DNS Cache for Faster Browsing

Wolfenstein: Enemy Territory Server Setup

How to Bind a Range of IPs

Screencast Guide: Capure Your Linux Desktop on Video!

READER COMMENTS:


Comment #1 by: maneschi on 19 Sep 2007, 05:48 UTC reply to this comment

I have just done this in Ubuntu 7.04 (Feisty). The parameter that matters on the server is in /etc/default/syslogd.


Comment #2 by: caenym on 20 Mar 2008, 18:21 UTC reply to this comment

In Debian 4.0 you will want to modify the file /etc/default/syslogd which /etc/init.d/sysklogd sources for the SYSLOGD variable.


Comment #3 by: joe on 19 Aug 2009, 13:13 UTC reply to this comment

Nice how-to! I did run into a snag though - iptables complains about using the -i eth0 flag for an output rule. Just take that piece out and its all good.

It would also be worth mentioning that iptables will not save the new rules unless you run the command iptables-save. Otherwise, you lose them when iptables or the server is restarted.

Thanks again!


Comment #4 by: JoseGpe on 23 Feb 2010, 20:50 UTC reply to this comment

ok thanks it helps me a lot. But now what if I want to change the path to de files storing messsages to redirect them to another device with more storage???


Comment #5 by: e ga on 26 Mar 2010, 09:47 UTC reply to this comment

hello,

how can i separate messages from one remote syslog into different files on my rsyslog server? It is ok if i forward all messages to one single file, but i can not separate coming messages to different files.

sorry for my poor english.
thanks.


Comment #6 by: Confused on 05 Nov 2010, 04:38 UTC reply to this comment

Hey I am having trouble adding Windows clients to the syslog server on Ubuntu. I have to log Windows server 2003 and Windows Xp but I do not know what I am missing. I have input the ip addresses to the ip table but I am confused on what I need to do in order for the syslog server to log the windows machine. Unfortunately, I do not have enough space on the client machines to add Kiwi or any other third party software, therefore, I have to figure it out via trial and error. Do I need to configure the client machines in order for them to send logs to the Ubuntu box or something? Please help


Comment #7 by: waxs on 25 Nov 2011, 04:51 UTC reply to this comment

Hye,
Let say I have 2 different server (webserver & database) and i want to syslog server store my log in different log.

example database.log & weserver.log

can i do that?
Thanks for your info & help

Copyright © 2001-2012 Softpedia. Contact/Tip us at

WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM