【问题标题】:Can someone explain the host argument in BPF有人可以解释 BPF 中的主机参数吗
【发布时间】:2018-07-03 16:29:42
【问题描述】:

我已经为此苦苦挣扎了一段时间,但我在网上找不到任何答案。查找文档并没有真正的帮助。我不明白 BPF 代码中的参数 host 应该代表什么或如何正确使用它。它的工作方式与net 相同吗? (不是说我知道net 做了什么,我只是假设它们可能相似)请帮忙。

【问题讨论】:

  • 你指的是tcpdump语法吗?能否添加一个带主机的 BPF 代码示例?

标签: winpcap bpf


【解决方案1】:

host 可用于匹配数据包中的目标或源 IP 地址,而 net 可用于匹配子网中的所有 IP 并采用 CIDR。例如:

# matches all packets with 192.168.1.1 as source or destination IP address:
host 192.168.1.1
# matches all packets with destination IP address 192.168.1.1
dst host 192.168.1.1
# matches all packets with a source IP address within 192.168.1.0-255 
src net 192.168.1.0/24

注意host 192.168.1.1 等同于net 192.168.1.1/32

来源:这一切都记录在https://www.tcpdump.org/manpages/pcap-filter.7.html

【讨论】:

    猜你喜欢
    • 2013-09-20
    • 2011-02-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-29
    • 2010-12-13
    • 1970-01-01
    相关资源
    最近更新 更多