basforge

Search titles, text and the “If it doesn’t work” cases.

    RU

    -i any in tcpdump: Linux SLL2 header, no destination MAC, and no promiscuous mode

    tcpdump -i any captures traffic across all interfaces at once and prints the interface name with direction (In/Out), but replaces the Ethernet header with a LINUX_SLL2 pseudo-header: destination MAC is missing, ether filters fail, and promiscuous mode stays off.

    How -i any differs from -i eth0

    Linux interfaces use different link layers: eth0 is Ethernet (EN10MB), wg0 (WireGuard) is pure L3 with no MAC addresses, and lo is loopback. To merge them into a single stream, libpcap wraps -i any packets in a synthetic 20-byte LINUX_SLL2 (Linux cooked capture v2) header.

    Compare the same ping -c 1 1.1.1.1 packet with -e (print link-level header):

    # On -i eth0: real Ethernet header (14 bytes), both MAC addresses visible:
    sudo tcpdump -nn -i eth0 -e -c 1 'icmp and host 1.1.1.1'
    # listening on eth0, link-type EN10MB (Ethernet), snapshot length 262144 bytes
    # 20:30:46.231251 bc:24:11:af:27:2b > e2:a1:e8:41:67:85, ethertype IPv4 (0x0800), length 98: 10.0.0.11 > 1.1.1.1: ICMP echo request, id 9705, seq 1, length 64
    
    # On -i any: LINUX_SLL2 pseudo-header (20 bytes), shows interface and direction, no Dst MAC:
    sudo tcpdump -nn -i any -e -c 1 'icmp and host 1.1.1.1'
    # listening on any, link-type LINUX_SLL2 (Linux cooked v2), snapshot length 262144 bytes
    # 20:30:35.825186 eth0  Out ifindex 2 bc:24:11:af:27:2b ethertype IPv4 (0x0800), length 104: 10.0.0.11 > 1.1.1.1: ICMP echo request, id 9681, seq 1, length 64

    Key differences when choosing the flag:

    Property -i eth0 (EN10MB) -i any (LINUX_SLL2)
    Interface name and In/Out in output no (single interface) yes (eth0 In, eth0 Out, lo In)
    Source and destination MAC (-e) both MACs (Src > Dst) source address only, no Dst MAC
    ether host, ether dst, ether src filters work filter compile error
    Promiscuous mode (non-local frames on switch/mirror) enabled by default disabled (man tcpdump)
    Duplicate lines across bridges and veth one frame, one line one transit packet appears on each interface

    When to pick -i any vs a specific interface

    • -i any — fast first look when you do not yet know which interface carries the packet (VPN route, local 127.0.0.53, Docker bridge br-*, or primary eth0). The interface name and In/Out direction immediately pinpoint the path.
    • A specific -i eth0 / -i br-… — when you need ether MAC filters, L2 and VLAN inspection, mirrored traffic capture (SPAN/mirror port requiring promiscuous mode), or a clean .pcap without bridge and veth duplicates.

    If it doesn’t work

    Running sudo tcpdump -nn -i any 'ether host bc:24:11:af:27:2b' fails with ethernet addresses supported only on ethernet/FDDI/...

    Cause
    The any pseudo-interface uses link-layer type LINUX_SLL2 (Linux cooked v2) instead of EN10MB (Ethernet), so MAC filtering via ether is unavailable.
    Fix
    Specify a concrete Ethernet interface: sudo tcpdump -nn -i eth0 'ether host bc:24:11:af:27:2b'.

    With -i any, every Docker container packet prints two or three times

    Cause
    any listens on eth0, the br-* bridge, and the host-side veth* at the same time — a single transit packet crosses each of those interfaces.
    Fix
    Read the interface label at the start of each line (eth0 In, br-… Out, veth… Out) — those are separate hops along the path, not network duplicates. For a clean capture, pick one interface with -i eth0 or -i br-….

    How to check

    Compare the supported data link types on a specific interface and on any using -L:

    sudo tcpdump -i eth0 -L
    # Data link types for eth0 (use option -y to set):
    #   EN10MB (Ethernet)
    #   DOCSIS (DOCSIS) (printing not supported)
    
    sudo tcpdump -i any -L
    # Data link types for any (use option -y to set):
    #   LINUX_SLL (Linux cooked v1)
    #   LINUX_SLL2 (Linux cooked v2)