iptables:log_firewall_messages_to_a_separate_file
Differences
This shows you the differences between two versions of the page.
iptables:log_firewall_messages_to_a_separate_file [2016/10/07 23:38] – created peter | iptables:log_firewall_messages_to_a_separate_file [2019/11/29 17:40] (current) – removed peter | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== IPTables - Log firewall messages to a separate file ====== | ||
- | |||
- | Issue the following command: | ||
- | |||
- | <code bash> | ||
- | sudo vi / | ||
- | </ | ||
- | |||
- | and comment out the following lines near the bottom of the file by placing a hash # mark in front: | ||
- | |||
- | <file bash / | ||
- | daemon.*; | ||
- | news.err;\ | ||
- | *.=debug; | ||
- | *.=notice; | ||
- | </ | ||
- | |||
- | to | ||
- | |||
- | <file bash / | ||
- | # | ||
- | # news.err;\ | ||
- | # *.=debug; | ||
- | # *.=notice; | ||
- | </ | ||
- | |||
- | There is a bug in the default installation, | ||
- | |||
- | Therefore this entire section if commented out. | ||
- | |||
- | Issue the following command: | ||
- | |||
- | <code bash> | ||
- | sudo vi / | ||
- | </ | ||
- | |||
- | and add the following lines to the file: | ||
- | |||
- | <file bash / | ||
- | # Log kernel generated iptable log messages to file | ||
- | : | ||
- | # Uncomment the following to stop logging anything that matches the last rule. | ||
- | # Doing this will stop logging kernel generated iptables log messages to the file | ||
- | # normally containing kern.* messages (eg, / | ||
- | & ~ | ||
- | </ | ||
- | |||
- | This logs all firewall related messages to / | ||
- | |||
- | |||
- | ===== Prevent the logfile getting to big ===== | ||
- | |||
- | Issue the following command: | ||
- | |||
- | <code bash> | ||
- | sudo vi / | ||
- | </ | ||
- | |||
- | and add the following lines to the file: | ||
- | |||
- | <file bash / | ||
- | / | ||
- | { | ||
- | rotate 3 | ||
- | daily | ||
- | missingok | ||
- | notifempty | ||
- | delaycompress | ||
- | compress | ||
- | postrotate | ||
- | / | ||
- | endscript | ||
- | } | ||
- | </ | ||
- | |||
- | A logrotate job is created to run daily to keep the log file from getting too large. | ||
- | |||
- | To view the firewall log file, issue the command: | ||
- | |||
- | <code bash> | ||
- | sudo cat / | ||
- | </ | ||
- | |||
- | |||
- | ===== Restart rsyslog ===== | ||
- | |||
- | Issue the following command: | ||
- | |||
- | <code bash> | ||
- | sudo service rsyslog restart | ||
- | </ | ||
iptables/log_firewall_messages_to_a_separate_file.1475883501.txt.gz · Last modified: 2020/07/15 09:30 (external edit)