Filtering Captures by MAC Address in Wireshark and tcpdump
Filtering by MAC address is the most common layer 2 troubleshooting operation. Wireshark has two syntaxes that are easy to confuse: capture filters use BPF, while display filters use their own expression language. Mixing them up is the most frequent source of early frustration.
Display filters: working on what you already captured
Display filters go in the filter bar of the main Wireshark window and apply to captured data.
eth.addr == 00:1b:a9:12:34:56 # matches either source or destination
eth.src == 00:1b:a9:12:34:56 # source only
eth.dst == 00:1b:a9:12:34:56 # destination only
eth.addr != 00:1b:a9:12:34:56 # exclude an address
Filtering by OUI is a genuinely useful trick when you want all traffic from one vendor's devices:
eth.addr[0:3] == 00:1b:a9 # match the first three bytes
[0:3] is slice syntax: take three bytes starting at offset zero. To confirm which company owns a prefix, check the vendor directory.
Isolating multicast and broadcast:
eth.dst == ff:ff:ff:ff:ff:ff # broadcast
eth.ig == 1 # all multicast, including broadcast
eth.lg == 1 # locally administered addresses
eth.lg == 1 is particularly handy because it picks out every client with randomisation enabled and every virtual interface in one go. The flag bits are explained in reading the first byte of a MAC address.
Capture filters: discarding before it hits disk
Capture filters use BPF syntax and drop non-matching packets in the kernel. On a busy link you have to use them, or disk and CPU will not keep up.
ether host 00:1b:a9:12:34:56 # source or destination
ether src 00:1b:a9:12:34:56 # source only
ether dst 00:1b:a9:12:34:56 # destination only
ether broadcast # broadcast frames
ether multicast # multicast frames
not ether host 00:1b:a9:12:34:56 # exclude
The two syntaxes are not interchangeable at all. Typing eth.addr == into the capture filter field is an immediate error, and the reverse fails too. A simple mnemonic: dotted names belong to display filters, space-separated keywords belong to capture filters.
tcpdump uses the same BPF syntax
# capture all traffic for one MAC
sudo tcpdump -i eth0 ether host 00:1b:a9:12:34:56 -w out.pcap
# ARP only, for resolution and spoofing problems
sudo tcpdump -i eth0 arp -nn
# traffic from one OUI, using a byte-offset comparison
sudo tcpdump -i eth0 'ether[6:4] = 0x001ba912'
The last one deserves explanation. Bytes 6 through 11 of an Ethernet frame hold the source MAC, and ether[6:4] takes four bytes for comparison. It is the workaround for BPF having no built-in OUI filter.
When investigating ARP, the -nn flag matters. It stops addresses being resolved to names, which is both faster and more truthful. It pairs well with the detection methods in ARP spoofing defence.
A few real scenarios
Find who is flooding broadcasts. Filter on broadcast first, then look at the statistics:
eth.dst == ff:ff:ff:ff:ff:ff
Open Conversations under the Statistics menu and sort on the Ethernet tab. The noisiest source address is immediately obvious.
Confirm whether a device is really communicating. Use its MAC as a capture filter and run for a few minutes. No packets at all means the device is offline or not in this broadcast domain, which is more reliable than ping because firewalls drop ICMP.
Investigate an IP and MAC mismatch. If the source MAC behind one IP changes mid-capture, either the device genuinely changed or something is spoofing. Looking up both MACs on the lookup page usually settles it at once.
Extra requirements for wireless
To see frames from other devices the adapter has to enter monitor mode:
sudo ip link set wlan0 down
sudo iw dev wlan0 set type monitor
sudo ip link set wlan0 up
Monitor mode gives up normal connectivity, and not every adapter or driver supports it. Capturing other people's traffic raises legal and compliance questions, so only do this on networks you own or have explicit authorisation to test.