The following code:
sniff(filter = "dst aa:bb:cc:dd:ee" )
throws an error because sniff
is expecting an IP, not a MAC.
So how are you supposed to filter by MAC?
The following code:
sniff(filter = "dst aa:bb:cc:dd:ee" )
throws an error because sniff
is expecting an IP, not a MAC.
So how are you supposed to filter by MAC?
what about specyfing a
lfilter
forsniff
?dst
andsrc
are attributes of sniffed message.previously i have posted an answer where
stop_filter
was specified. i suppose that it wouldn't work for you, since scapy would stop after receving first packet that match the mac address fromstop_filter
.lfilter
should do the job.from
sendrecv.py
:The
filter
parameter needs a BPF filter. The correct syntax is hencefilter="ether dst aa:bb:cc:dd:ee:ff"
.This is (much) faster than using a Python function as
lfilter
parameter, as suggested (correctly) by macfij in another answer (plus you don't have to deal with upper/lower-case letters in MAC addresses).