One*_*unk 3 iptables tcpdump packet
我试图找到一种方法来记录根据 iptables 中的规则丢弃的数据包(可能使用 tcpdump)的全部内容。
目前,我有一个规则来记录这些数据包(带有日志前缀),然后按照这个规则来删除它们。
有没有办法记录这些数据包的内容以供以后查看?
所以,我正在寻找这个:
2 & 3 甚至可以组合。
我的理解是 tcpdump 可能无法做到这一点,因为它在iptables之前检查数据包,因此不会只记录丢弃的数据包。
谢谢。
NFLOG 目标可用于此目的。这是一个非常基本的例子:
# Drop traffic by default
iptables -P INPUT DROP
# add your whitelists here
# iptables -A INPUT ...
# Pass the packets to NFLOG (just like LOG, but instead of syslog,
# it uses netlink). You can add extra filters such as '-p tcp' as usual
iptables -A INPUT -j NFLOG
# packets that get here will now be dropped per INPUT policy
# Finally you can use tcpdump to capture from this interface (there
# can only be one active user of nflog AFAIK)
tcpdump -i nflog ...
Run Code Online (Sandbox Code Playgroud)
iptables-extensions有关NFLOG目标的说明,请参阅手册页。
| 归档时间: |
|
| 查看次数: |
4682 次 |
| 最近记录: |