我正在尝试使用IPtables的TRACE目标,但我似乎无法获取任何logging的跟踪信息。 我想使用这里描述的: debugging器为Iptables 。
从iptables man for TRACE:
This target marks packes so that the kernel will log every rule which match the packets as those traverse the tables, chains, rules. (The ipt_LOG or ip6t_LOG module is required for the logging.) The packets are logged with the string prefix: "TRACE: tablename:chain- name:type:rulenum " where type can be "rule" for plain rule, "return" for implicit rule at the end of a user defined chain and "policy" for the policy of the built in chains. It can only be used in the raw table.
我使用以下规则: iptables -A PREROUTING -t raw -p tcp -j TRACE但是在/ var / log / syslog或/var/log/kern.log文件中没有任何内容。
是否还有一步失踪? 我在错误的地方看吗?
即使我找不到日志条目,TRACE目标似乎设置正确,因为数据包计数器增加:
# iptables -L -v -t raw Chain PREROUTING (policy ACCEPT 193 packets, 63701 bytes) pkts bytes target prot opt in out source destination 193 63701 TRACE tcp -- any any anywhere anywhere Chain OUTPUT (policy ACCEPT 178 packets, 65277 bytes) pkts bytes target prot opt in out source destination
规则iptables -A PREROUTING -t raw -p tcp -j LOG 确实将数据包信息打印到/ var / log / syslog …为什么TRACE不起作用?
你需要运行:
modprobe ipt_LOG.
这是为我做的。
似乎(即适用于我)需要新的内核(对于IPv4):
modprobe nf_log_ipv4 sysctl net.netfilter.nf_log.2=nf_log_ipv4
积分:
我发现我需要按以下顺序执行前面的两个答案:
sudo modprobe ipt_LOG sudo sysctl net.netfilter.nf_log.2=ipt_LOG
这里有一些我一路上发现的东西。
您可以通过以下方式获得有效的logging器列表(以及当前选定的logging器):
cat /proc/net/netfilter/nf_log
这里的数字表示协议族编号,如在/usr/include/bits/socket.h定义的。 2是AF_INET (即IPv4),10是AF_INET6 (IPv6)。
这为我工作sudo sysctl net.netfilter.nf_log.2=ipt_LOG