mansis
mansis

Reputation: 33

How do I set the IP range for Scapy Sniff filter?

I try to do the below filter in my Sniff function:

pkt = sniff(count=1, iface='Qualcomm Atheros QCA61x4A Wireless Network Adapter', filter='host 178.0.0.0/8')
try:
    print(str(pkt[0][1].src)+'-->'+str(pkt[0][1].dst)+":::"+str(pkt[0][3].load))
except:
    pass

But this filter do not work, instead, the code prints the traffic to all hosts and not the 178.0.0.0/24

Upvotes: 0

Views: 1226

Answers (1)

Qeole
Qeole

Reputation: 9124

Assuming your filter is compiled by the libpcap, host does not work with CIDR blocks (network + mask). It takes a name or an IP address (v4 or v6).

Instead you want to use net:

... filter='net 178.0.0.0/8')

Upvotes: 1

Related Questions