Firewall – prevent some of the UFW messages from being logged

firewallloggingrsyslogufw

My router broadcasts (sends to 224.0.0.1) something every forty seconds. This is caught by UFW which stores a log entry in syslog:

Jan 5 03:49:02 log kernel: [ 1184.788900] [UFW BLOCK] IN=eth0 OUT= MAC=01:00:5e:00:00:01:40:5a:9b:5c:9c:fd:08:00 SRC=192.168.1.1 DST=224.0.0.1 LEN=32 TOS=0x00 PREC=0x80 TTL=1 ID=0 DF PROTO=2

I am about to set up a syslog server which will collect messages from each of network's 50 machines. Polluting the syslog with 50 messages every forty seconds annoys me, and the router itself is unfortunately not configurable.

Is there a way to prevent those particular messages (filtered by source and destination) to be logged, while still logging other entries which are blocked by the firewall?

Best Answer

Yes.

  1. For rsyslog, you can use a filter such as:

    :msg, contains, "MAC=01:00:5e:00:00:01:40:5a:9b:5c:9c:fd:08:00 SRC=192.168.1.1 D ST=224.0.0.1" ~

    If you put it before other configuration rules, it will prevent the messages from being logged. You can see a full example of a configuration file here.

    Note that the text “must be an exact match, wildcards are not supported.

  2. For syslog-ng, use some variation of the filters, with a not message('someregex') in your filter.