How to Determine the Switch a Linux Server is Connected to

To determine what switch you are connected to (this is only known to work on Cisco switches as it replies on CDP (Cisco Discovery Protocol) but may also work on others), run the following command under Linux.

tcpdump -nn -v -i <INTERFACE> -s 1500 -c 1 ‘ether[20:2] == 0x2000’

This may take 30 seconds or so to come back but will give you switch information including the IP address.

We hope you find this article informative. Please share it with your friends, colleagues, and on all your favorite social sites. Let us know what interests you, and we will write it. Don’t forget to leave a comment.