Iptables log file

iptableslogs

I have ubuntu and I want to know where can I find the log file of iptables?
I find out /var/log/messages, but I am not sure this is a correct log file or not.

And I also want to know when this log file is changed? I add one rule to prevent my machine to respond to ping message but when I ping my machine I didn't see any changes to /var/log/messages

Best Answer

Because it can easily fill up your logs, the default is to not log. Add a jump to the LOG target, which will log to the kernel log (which you can see with dmesg or at wherever syslog is configured to write that for your distro). In your LOG-target rule, you can set --log-level and --log-prefix to help organize the messages and keep them separate from other kernel messages.

LOG is a "non-terminating target", so rule traversal will continue on to the next rule — you can basically add logging right above your existing rules without affecting them.

Related Question