Cisco Discovery Protocol linux client?
Wondering how to query a Cisco switch for its CDP information from linux?
|
1 Attachment(s)
Do you want to listen to the cdp information that is flowing on the network or extract the cdp info from the devices you discover.
If the former, all you'll see is the data from your local switch or router. Your question sounds like you are looking for the latter. If the latter, I've attached a perl program that I used in a prior job that would collect all of the cdp info so that I could create a network topology in a modeling program. (Rename the file to remove the .txt suffix that was required for upload.) I can't find the original source code from the original author, but this modified copy worked quite well for me. The one caveat is that the Cisco devices may be set up to restrict access to cdp data. My former employer's audit department had instructed the network engineers to do just that. I left just in time. If you can't get to the cdp mibs with a "mib walker" you won't be able to get them with this perl program. hope this helps. |
Do you have a sample configuration file for this?
------ Previous issues kept for archive This seems to be what I am looking for. In the first few lines though, it states: Quote:
Quote:
The error previous to that was: Quote:
Quote:
|
Oops. Sorry. Remove that line. That was where I downloaded required module to, from CPAN. (I didn't have any authority to install modules into the standard Perl location, as I was just an unprivileged user.)
I think the three modules that are needed, BER.pm, SNMP_Session.pm and SNMP_util.pm, all came from CPAN.org. |
I guess a comment in package POE::Component::SNMP::Session says it best
Quote:
I found on my Fedora 14 system that if I did a 'yum install net-snmp-perl' (not certain if this is needed); a 'yum install perl-Net-SNMP'; and a 'yum install perl-SNMP_Session', I could run cdp.pl and get the same results as you. Code:
[root@athlon ~]# ./cdp.pl The fourth line, "[Warning] No configuration file or incorrect file name, use default" is emitted from the subroutine initConf (near line 522). It's saying that there isn't a config file. By default it is '/etc/cdp_conf.txt' or 'cdp_conf.txt' in your current directory. When I add that file to my current directory and seed it with a starting ip address of 192.168.1.1, I get one step further and then it bombs. Code:
[root@athlon ~]# ./cdp.pl I'll look at this further in the morning. It's past midnight and my brain is shutting down. btw, I don't have any Cisco gear at home, so I can only test this so far, but hopefully I can at least get it to run cleanly. |
Well, here's some sloppy code.
Well, here's some sloppy code... Code:
sub get_set_restore { Code:
sub set_list_to_names_and_oids{ I loaded up the cdp_conf.txt file with non Cisco IP addresses, Code:
[root@athlon ~]# cat cdp_conf.txt Code:
[root@athlon ~]# ./cdp.pl I can't run it in work. I'm a Linux engineer and this would really exceed my job function and probably would be viewed as a hacking/intrusion attempt... There is zero tolerance for experimentation if it's outside of our job function, i.e. grounds for termination. Have you seeded it with a starting Cisco device IP address and gotten it to discover other Cisco devices? |
Clean/simple CDP
I was trying to query CDP info on a low spec netbook today and came across this post.
The perl solutions elsewhere in this thread were a bit complex/heavy for my situation, but I found this: https://github.com/yurividal/tuxCDP/ You only need to have tcpdump and awk installed - worked great for me (and the coloured text output was a nice touch). |
All times are GMT -5. The time now is 12:12 PM. |