Capturing CDP Packets with tcpdump

An oldie, but a goodie.

Using tcpdump, you can filter for the first CDP packet received by a given network interface. This can contain super-useful information for troubleshooting network issues.

tcpdump -nn -v -i eth0 -s 1500 -c 1 'ether[20:2] == 0x2000'

Big ones for me are Native VLAN ID and Port-ID, both invaluable when figuring out why you can’t hit that elusive default gateway!