IPTables: How to log and set a specific log file
12,287
You can do this my configuring iptables to 'mark' the messages e.g.
iptables -A INPUT -s 192.0.2.0/24 -j LOG --log-prefix='[iptables] '
Which will cause a log message that is prefixed with the text [iptables]
Now you can configure your rsyslog to send these messages to a particular log file by adding a suitable entry to it's configuration e.g.
:msg,contains,"[iptables] " /var/log/iptables.log
Related videos on Youtube
![Admin](/assets/logo_square_200-5d0d61d6853298bd2a4fe063103715b4daf2819fc21225efa21dfb93e61952ea.png)
Author by
Admin
Updated on September 18, 2022Comments
-
Admin almost 2 years
Is it possible log all dropped connections by IPTables and set a iptables.log file for logging in /var/log/?