How can I configure /etc/syslog.conf
file in order to save log information about iptables
in a specific file.
I want to save these information separately, so I can extract what I want easily and rapidly.
iptableslinuxsyslog
How can I configure /etc/syslog.conf
file in order to save log information about iptables
in a specific file.
I want to save these information separately, so I can extract what I want easily and rapidly.
Best Answer
syslog
Take a look in the man page for
iptables
. It shows a target calledLOG
which can do what you want.Example
Set the logging level for
LOG
to 4.Configure
syslog.conf
to write these messages to a separate file.Restart syslogd.
Debian/Ubuntu
Fedora/CentOS/RHEL
NOTE: This method of logging is called fixed priorities. They are either numbers or names (1,2,3,4,..) or (DEBUG, WARN, INFO, etc.).
rsyslog
If by chance you're using
rsyslog
, you can create a property based filter like so:Then add thils switch to your iptables rules that you want to log:
As an alternative you could also log the messages using this type of property filter:
NOTE: This 2nd method doesn't require any changes to
iptables
.References