Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have IPTables rules set on a Linux device. I have a particular rule to drop the packets, and I wish to log the packets only if they're dropped by that specific rule, and not by the other rules.

Hence not written out to the syslog.

share|improve this question

1 Answer 1

You could use rsyslog and set a custom --log-prefix on this specific rule when you're setting it up. This would allow you to setup a rsyslog rule to route any messages with this custom prefix to a individual log file.

This tutorial titled: Change the IPTables log file, shows the exact methodology. In general you'll setup your iptables rule like so:

$ sudo iptables -A INPUT -p tcp --dport 22 --syn -j LOG --log-prefix "iptables: "

And then create a corresponding rsyslog rule to log messages with this prefix:

# /etc/rsyslog.d/10-iptables.conf
:msg, contains, "iptables: " -/var/log/iptables.log
& ~
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.