9.4. Restrict console messages

9.4.1. Restrict console messages from the system log

Generating a stready stream of console messages can easily overwhelm a 9600bps link.

Although displaying all syslog messages on the console appears to be a good idea, this actually provides a nice method to deny effective use of the remote console.

Configure log messages to the console to the bare minimum, especially if the machine is sending syslog messages to a remote log server. Look in /etc/syslog.conf for lines ending with /dev/console.

None of the above prevents all log messages being sent to another machine for recording and analysis. Figure 9-2 shows the standard /etc/syslog.conf from Red Hat Linux 7.2 modified to record log messages to a log server. Each line of syslog.conf has been repeated to send a copy of the message to the log server. The log server has the DNS alias loghost.example.edu.au; this allows the log server to be moved without updating the configuration of all the remote machines. The local copy of the log message is no longer the only means of determining the cause of a system failure, so we can gain some performance advantage by disabling synchronous file writes, although this increases the odds of an inconsistent filesystem (an issue with filesystems that do not do journalling). Placing a - before the filename disables synchronous file writes.

A log server is configured using the standard /etc/syslog.conf and also allowing remote syslog messages, shown for Red Hat Linux in Figure 9-3. Additionally, denial of services attacks are prevented by configuring IP Tables to restrict the sources of the syslog messages; and performance is improved by checking that nscd is running to cache reverse DNS lookups.

9.4.2. Restrict console messages from broadcast messages

Users that are logged into the serial console should not accept broadcast messages. Add new files to /etc/profile.d to do this. Figure 9-6 shows a file for use by the Bourne shell.

As this file is run frequently, we use a faster but less readable version of Figure 9-6, shown in Figure 9-7.

We also need a C shell version, shown in Figure 9-8.

Although mesg.sh and mesg.csh are included by the parent shell rather than executed, the files need the execute permission set. The procedure in Figure 9-9 installs the files and sets the permissions.