我如何设置iptables的方式,我知道什么包被哪个规则阻止? 我所知道的一个解决scheme是-j LOG – 日志前缀。 有没有其他的方法?
您可以查看数据包/字节计数器:
防火墙(2引用)
pkts字节目标人选退出源目的地73M 42G ACCEPT all – lo * 0.0.0.0/0 0.0.0.0/0
您可以使用“-Z”选项清除计数器。 如果要跟踪源,可以将数据包的types指向自己的表,并根据源接收数据包。
iptables -N SMTP iptables -I INPUT -p tcp --dport 25 -j SMTP iptables -A SMTP -s $network_1 -j ACCEPT iptables -A SMTP -s $network_2 -j ACCEPT iptables -A SMTP -j RETURN #Track by network instead of application iptables -N NETWORK_1 iptables -I INPUT -s $network_1 -j NETWORK_1 iptables -A NETWORK_1 -p tcp --dport 25 -j ACCEPT -m comment --comment "MAIL" iptables -A NETWORK_1 -p udp --dport 10000:20000 -j ACCEPT -m comment --comment "VOIP RTP" iptables -A NETwORK_1 -p tcp -m multiport --dports 80,443 -j ACCEPT iptables -A NETWORK_1 -p tcp -j ACCEPT -m comment --comment "UNKNOWN TCP" iptables -A NETWORK_1 -j RETURN -m comment --comment "This rule is not required but used for ip accounting"
还有-J ULOG,可以和ulogd一起使用。
看看TRACE目标
这个目标标记数据包,以便内核将logging与数据包相匹配的每个规则,如遍历表,链,规则。 (logging需要使用ipt_LOG或ip6t_LOG模块。)数据包以string前缀“TRACE:tablename:chainname:type:rulenum”logging,其中type可以是普通规则的“rule”,隐式规则是“return”在用户定义的链条的末端和用于内置链条的策略的“策略”。 它只能用在原始表格中。