对于PSAD的工作,我需要添加以下iptables规则并启用数据包日志logging:
iptables -A INPUT -j LOG iptables -A FORWARD -j LOG ip6tables -A INPUT -j LOG ip6tables -A FORWARD -j LOG
我在我的系统上使用UFW。 那么,我怎样才能用UFW添加这些规则呢?
您只需启用日志logging 。
sudo ufw logging on
正如上面的海报所说,你将需要启用日志与命令
sudo ufw logging on
但是我发现我仍然需要添加iptables规则。 要做到这一点,运行下面的每个命令(注意,你必须在前面有sudo )
sudo iptables -A INPUT -j LOG sudo iptables -A FORWARD -j LOG sudo ip6tables -A INPUT -j LOG sudo ip6tables -A FORWARD -j LOG
你需要添加额外的规则来满足psad。 编辑以下两个文件:
sudo vi /etc/ufw/before.rules sudo vi /etc/ufw/before6.rules
对于上面列出的两个文件, 添加 psad的最后一行 ,但在 COMMIT 之前
# custom logging directives for psad -A INPUT -j LOG -A FORWARD -j LOG # don't delete the 'COMMIT' line or these rules won't be processed COMMIT
接下来重新启动ufw
sudo ufw disable sudo ufw enable
然后检查它是否工作
sudo psad --fw-analyze [+] Parsing /sbin/iptables INPUT chain rules. [+] Parsing /sbin/ip6tables INPUT chain rules. [+] Firewall config looks good. [+] Completed check of firewall ruleset. [+] Results in /var/log/psad/fw_check [+] Exiting.
而已。 阅读有关如何使用UFWconfigurationPSAD的更多提示和技巧
就像darronz提到的,你还是要添加iptable规则。 在使用ufw时,创build永久性规则的最简单方法是编辑/etc/ufw/before.rules和/etc/ufw/before6.rules并添加以下行
-A INPUT -j LOG -A FORWARD -j LOG
最后,但在COMMIT之前。