When a system becomes compromised, and the intruder obtains elevated root privileges, he now has the ability, as well as the will, to trash any and all eviden ce leading up to the intrusion, on top of erasing anything else thereafter, including other key system files.
That's where remote system logging comes in, and it's real super-easy to set up.
This example uses Slackware Linux 8.1 as the base to begin, but
can be applied easily to other distros using the syslog daemon that was
ported to Linux by Mar
tin Schulze (
Since this is going to require more than one server, it's logical to conclude that you will have to pick and choose a server with which to make the centralize d parental tattle-tale of your network. Pick the server with the least amount of traffic, particularly, any server that doesn't utilize any heavy UDP traffic, si nce this is what syslogd will be using. Database servers should NEVER be used since they rely on space as much as the syslog facilities do, as will become appare nt later on in this document. Double check your services file in /etc to see if port 514 is listed. If it's not, put the following entry into it:
syslog 514/udp |
Since all the distributions I've played with have it listed, chances are, you won't need to modify it.
There is probably already a script somewhere during your startup processing that starts the syslogd. By default, the syslogd no longer listens to remote conne ctions on port 514. In fact, it's been disabled until it's explicitely turned on.
Find the script that starts the syslogd and add -r to the end of the line that executes it:
/sbin/syslogd -r (plus anything else that comes up with it) |
The -r switch tells the syslogd to start listening to the world on UDP port 514.
The problem with Step Two is that implementing it just like that opens up a wealth of problems, not the least of which is the potential for someone to step up to the plate and DoS the hell out of you on that port with bogus packets.
The quickest way to prevent this is simple packet filtering. Since iptables is now a defacto in almost every distribution with a 2.4.x kernel, I'll use it as my base, however, ipchains should be just as simple to set up:
iptables -A INPUT -p udp -s 192.168.2.0/24 -d 0/0 --destination-port 514 -j ACCEPT iptables -A INPUT -p udp -s 0/0 -d 0/0 --destination-port 514 -j REJECT |
ipchains -A INPUT -p UDP -s 192.168.2.0/24 -d 0/0 514 -j ACCEPT ipchains -A INPUT -p UDP -s 0/0 -d 0/0 514 -j REJECT |
Summary: let's listen to all the machines on our own network, but reject everything else on port UDP 514. This keeps our head above water in listening to the computers that belong to us. If you put this into a startup script, remember that the REJECTion line MUST come LAST in the process or the packets won't get throu gh. Unfortunately, ordering is everything, but then again, order can be a good thing.
Now that the parent is ready to listen, it's time to prep our children. For every child computer you have that is going to talk to our parent, you may need to tell it who the parent is that it will be talking to. Afterall, we wouldn't want our children talking to strangers, now would we?
For this, we have /etc/hosts. Modify it with the IP of the listening parent server:
192.168.2.23 parent.somedomain.com |
The child can then relate its listening parent to @parent instead of the whole IP address or domain name, which will become apparent in the next step.
The final step in our remote syslogging setup is to actually tell the children what type of information is going to be sent back to our parent. The following is my example of a default /etc/syslog.conf for all of the child systems that will be sending data to our parent logging facility:
# /etc/syslog.conf # For info about the format of this file, see "man syslog.conf" # and /usr/doc/sysklogd/README.linux. # Uncomment this to see kernel messages on the console. # kern.* /dev/console # We don't want to uncomment it - makes a messy screen. # Log anything 'info' or higher, but lower than 'warn'. # Exclude authpriv, cron, mail, and news. These are logged elsewhere. *.info;*.!warn;\ authpriv.none;cron.none;mail.none;news.none @parent # Log anything 'warn' or higher. # Exclude authpriv, cron, mail, and news. These are logged elsewhere. *.warn;\ authpriv.none;cron.none;mail.none;news.none @parent # Debugging information is logged here. *.=debug @parent # Private authentication message logging: authpriv.* @parent # Cron related logs: cron.* @parent # Mail related logs: mail.* @parent # Emergency level messages go to all users: *.emerg @parent # This log is for news and uucp errors: uucp,news.crit @parent # You can include any others that you need as long as they follow the # format stated by the syslog.conf man page. |
After setting up something like this, you can then restart the children's syslogging facility and they should start talking to the parent on UDP port 514.
Check to make sure this is the case. I did find that not specifying who the parent was in step four above was important enough to disallow the child sending a nything out to the world. Could be because my DNS wasn't set up properly to reverse resolve.
Explaining what each line does is beyond the scope of this document. What this document basically is, is a primer to get the remote syslog working on your net work. After you have it set up, go read the syslog.conf man page for more information on what the parameters are.
The pros of setting up remote logging are quite simple, and make strategically logistical sense to administrators not wanting to waste time connecting to diff erent machines. Let's take a look:
The cons are seriously outweighed by the pros in terms of merit, however, they are worth mentioning: