scapy包过滤

Packet filtering with scapy

如何过滤来自特定 IP 和子网的数据包?这是我到目前为止所得到的:

from scapy.all import *

def print_packet(pkt):
    print pkt.summary()

pkt=sniff(filter = 'tcp and host = <source IP address>', prn=print_packet)

可以使用 CIDR 表示法匹配子网:

filter = "tcp and src='192.168.2.0/24'"