How to stop CSF messages from flooding your console AlmaLinux/RHEL

Many CSF (firewall) users experience an issue where their server console is flooded with CSF messages regarding dropped connections.

While CSF needs to log these actions to /var/log/messages to ensure the port scan feature works, you may not want to see these messages in the console.

 

Check Current Kernel Printk Values

First, determine the current kernel printk values by using the following command:

cat /proc/sys/kernel/printk

 

If the output starts with a number equals to or greater than 5, such as:

7       4       1       7

It starts with 7, this indicates that printk is configured to print everything to the console.

These are the default values in most RHEL/Almalinux systems.

 


 

Understanding Log Levels

The numbers represent the log level, which determines which messages appear on the console. You can adjust the log level based on your needs:

  • 0 – Emergency
  • 1 – Alert
  • 2 – Critical
  • 3 – Error
  • 4 – Warning
  • 5 – Notice
  • 6 – Info
  • 7 – Debug

For instance, if you select 3 (Error level), messages at levels 3, 2, 1, and 0 will appear in the console. Selecting 7 means all messages below that level will be printed.

 


Change Kernel Printk Settings

  1. To adjust the printk settings, open the configuration file:
    nano /etc/sysctl.conf
  2. Add the following line to the end of the file if it's not already present:
    kernel.printk = 4 4 1 7
  3. Use the following command to apply the changes without rebooting:
    sysctl -p
  4. Verify the changes with this command:
    cat /proc/sys/kernel/printk

    The output should now display:
    4       4       1       7

 

 

Now your console will no longer print CSF messages along with any other Debug, Info, and Notice messages, and will only show warning messages and the below log levels (Warning, Error, Critical, Alert, and Emergency).

  • CSF, Kernel, Console
  • 326 Users Found This Useful
Was this answer helpful?

Related Articles

How to reinstall an OS on my server?

If you already have an OS installed on your server and want to change or reinstall it, you can do...

How to set rDNS records for my dedicated server IPs?

You can update rDNS records of your server IPs from Client Area (One Portal) Log in to your...

How to change SSH Port on CentOS 6

Open SSH connection to the server, then:1. Type: nano /etc/ssh/sshd_config 2. Press CTRL+W to...

Do you provide KVM/IPMI access?

Yes, we provide KVM access to all servers in all locations.KVM access is free of charge in all...

Can I install a custom OS?

Yes, you can install a custom OS (OS that is not listed on the server order page) by attaching...