TCPDump Expression to Collect VLAN Tag ID Only – VLAN, TCPDump

tcpdumpvlan

Is there a tcpdump expression that collects the vlan tag id only?

I have an interface that has multiple vlan tagged traffic flowing through it. I can write expressions looking for IP pairs, or specific vlan but I want a list of vlan tags only.

Thanks, J

PS. Apologies for mistakenly posting this in Stack Overflow first

Best Answer

tcpdump -i <interface> -n -l -e vlan | awk -F'[ ,]' '{print $15}' 

This command uses awk to extract and print the VLAN tag ID, assuming it's in the 15th column of the output. Adjust the column number if needed based on your tcpdump output.