Introduction
CDP (Cisco Discovery Protocol) allows Cisco devices to be identified among them. For example, this system is used to find the IP address or port that is connected to another Cisco equipment. Broadly, this is a proprietary protocol that handles to send multicast information (every 60 seconds) to each device connected to accelerate identification.
For people who don’t have a Cisco network, there is another standardized protocol named LLDP offering more or less the same services. In our case we use the CDP because it is enabled by default on all our equipment (the LLDP integration is in another post).
Recovering the CDP information from our clients it is possible to quickly find the network location of each and to map automatically the infrastructure.
Example :
bash-3.2# ./cdpr cdpr - Cisco Discovery Protocol Reporter Version 2.4 Copyright (c) 2002-2010 - MonkeyMental.com 1. en0 (No description available) 2. fw0 (No description available) 3. en1 (No description available) 4. lo0 (No description available) Enter the interface number (1-4):1 Using Device: en0 Waiting for CDP advertisement: (default config is to transmit CDP packets every 60 seconds) Device ID value: C25-003-SW01 Addresses value: 10.xxx.xxx.xxx Port ID value: GigabitEthernet1/0/8
Compile cdpr for Mac OS X
Several existing tools can retrieve the CDP information from a Mac. The solution that seems the easiest to use is available on Source Forge under the project name cdpr.
Before you begin this step, it is necessary to install Xcode from the Mac App Store and the “Command Line Tools”. These are in the Xcode preferences in the “Downloads”. This is required to get the GCC compiler to prepare a Mac version of cdpr.
– Download cdpr from the project site and unzip the files.
– Go from Terminal in the cdpr folder where are the sources of the application.
cd ~/Downloads/cdpr-2.4
– Run the command “make” to perform the compilation.
make
– If the command does not return an error, a new binary called “cdpr” is available in the directory. It can be moved more or less anywhere because it works without file dependency.
Usage
It is possible to use the software in two ways, the first is simply to run cdpr and an intuitive interface will open in Terminal. It will ask you to select the network interface that you want to display CDP information.
The software also supports the execution of the command by arguments to use information more easily in a script.
cdpr -d en0
While this story is a few years old, I wanted to make note to those reading that cdpr is now included in Homebrew. You can easily install using “brew install cdpr”.
cdpr requires root privileges to get interface information. You can modify the permissions on the file to not require sudo by doing the following:
(As of this post, cdpr is version 2.4)
$ cd /usr/local/Cellar/cdpr/2.4/bin
$ sudo chown -R root cdpr
$ sudo chmod 4555 cdpr
My machine uses en4 to connect to the network:
$ cdpr -d en4
cdpr – Cisco Discovery Protocol Reporter
Version 2.4
Copyright (c) 2002-2010 – MonkeyMental.com
Using Device: en4
Waiting for CDP advertisement:
(default config is to transmit CDP packets every 60 seconds)
Device ID
value: CS-2960X-Core.net.domain.local
Addresses
value: 192.168.50.80
Port ID
value: GigabitEthernet4/0/14
Thanks! Yes, this post is not updated but the concept remains the same. Homebrew is great, but not really popular in enterprise.