如何使用“psad”实用程序configuration防火墙以避免端口扫描

我正在尝试configurationpsad来停止端口扫描和其他攻击。

目前我有我的防火墙设置下面的规则,除了端口22,80,443和3306以外的所有传入连接。

  -A INPUT -j DROP -A FORWARD -j DROP 

我想用“psad”。 “psad”提到的主要要求是“与psad兼容的iptables策略就是iptableslogging数据包”

  iptables -A INPUT -j LOG iptables -A FORWARD -j LOG 

那么如何configuration我的防火墙规则呢?

  1. 我应该先logging下来然后放下吗?

     -A INPUT -j LOG -A FORWARD -j LOG -A INPUT -j DROP -A FORWARD -j DROP 
  2. 我应该不使用滴吗? 我有点怀疑没有下降。

iptables manpage:

 LOG Turn on kernel logging of matching packets. When this option is set for a rule, the Linux kernel will print some information on all match- ing packets (like most IP header fields) via the kernel log (where it can be read with dmesg or syslogd(8)). This is a "non-terminating tar- get", ie rule traversal continues at the next rule. So if you want to LOG the packets you refuse, use two separate rules with the same matching criteria, first using target LOG then DROP (or REJECT). 

“不终止”是这里的关键术语。 您可以将LOG目标放在任何你喜欢的地方,并且理解在LOG条目之前“终止”的任何目标都不会被logging。

您需要智能地构build防火墙规则。 PSAD通过监视系统连接的日志来工作,然后基于各种启发式决定是否有人正在扫描您的系统。

LOG目标是非终止的,所以一旦一个数据包被logging,它就被传回原始链中作进一步处理

大致你需要:

  • 允许连接到22,80,443和3306 而不logging。
  • 将其他所有内容发送到LOG目标。
  • 最后应该有一个默认的下降规则和/或策略应该放弃。