📜 ⬆️ ⬇️

CDP and Linux

For those who work with Cisco equipment, such a convenient protocol as Cisco Discovery Protocol (CDP) is known, it is convenient to explore the network with its help, a rare administrator will want to disable his support in his network (of course, for our external neighbors, we definitely say no cdp en ).

Sooner or later the question becomes whether there is full or at least some kind of support for CDP in Linux and other * nix-systems. It turns out there is such a tool. Under the cut will be lit two of them.

cdpr is a small program that can listen to the CDP protocol on the specified interface.

Installing the cdpr package is not difficult, in Debian it is done like this:
  aptitude install cdpr 

After the package is installed, you can enter cdpr -help to get help with the description of the program options. (It should be noted that cdpr is installed in / usr / sbin, so a simple user must enter either the full path or work with root rights, for example via sudo)
  $ sudo cdpr -help
 cdpr - Cisco Discovery Protocol Reporter
 Version 2.2.1
 Copyright (c) 2002-2006 - MonkeyMental.com

 d: Specify device to use (eth0, hme0, etc.)
 h: Print this usage
 waiting for a packet (should be> 60)
 v [vv]: Set verbose mode

 ** Options dealing with server updates: **
  u: Send cdpr information to a cdpr server
     requires config file as arg
  l: Location / description of this port for use with -u or -s and -p
  override with -u or -s and -p
  Server: Server / IP
      Example: 192.168.1.20:88 (default: 80) requires -p (overridden by -u)
  p: Path to server to send data to requires -s (overridden by -u) 

Running cdpr without specifying options displays a simple menu where you can select the interface from which we want to get information on CDP:
  $ sudo cdpr
 cdpr - Cisco Discovery Protocol Reporter
 Version 2.2.1
 Copyright (c) 2002-2006 - MonkeyMental.com

 1. eth0 (No description available)

 [... skip ...]

 22. any (Pseudo-device that captures on all interfaces)
 23. lo (No description available)
 24. lo: ring (No description available)
 Enter the interface number (1-24): 13 

Specify the number of the network interface from the menu and patiently wait while cdpr will analyze the information coming from the interface:
  Using Device: vlan1315
 Waiting for CDP advertisement:
 (default config is to transmit CDP packets every 60 seconds)
 Device ID
   value: cisco.netcom.ks.ua
 Addresses
   value: 213.44.40.27
 Port id
   value: FastEthernet0 / 1.1315 

Hooray! There is a contact! True, there is no place easier? ;)
')
But if you look closely at the output of cdpr --help, then you will notice that it is not necessary to work with the program through the menu, you can also specify the interface of interest through the -d option, and at the same time enable a more verbose mode of operation, specifying -v or -vvv:
  $ sudo cdpr -d vlan1315 -vvv
 cdpr - Cisco Discovery Protocol Reporter
 Version 2.2.1
 Copyright (c) 2002-2006 - MonkeyMental.com

 Using Device: vlan1315
 Waiting for CDP advertisement:
 (default config is to transmit CDP packets every 60 seconds)
 Received a CDP packet, header length: 372

 cdp packet:
   version: 02
   time to live: b4
   checksum: cfcb

 cdp type / len / val:
   type: 0001 - Device ID
   length: 0016
 Device ID
   value: cisco.netcom.ks.ua

 cdp type / len / val:
   type: 0005 - Software version
   length: 00fc
 Software version
   value: Cisco IOS Software, 2800 Software (C2800NM-ADVIPSERVICESK9-M), Version 12.4 (12), RELEASE SOFTWARE (fc1)
 Technical Support: http://www.cisco.com/techsupport
 Copyright (c) 1986-2006 by Cisco Systems, Inc.
 Compiled Fri 17-Nov-06 12:02 by prod_rel_team

 cdp type / len / val:
   type: 0006 - Platform
   length: 000e
 Platform
   value: Cisco 2811

 [... skip ...]

 cdp type / len / val:
   type: 000b - Duplex
   length: 0005
 Duplex
   value: 01 
 Data Link Type: Ethernet (10MB, 100MB, 1000MB and up). 

Note that the output obtained via cdpr, if necessary, is quite convenient to analyze in any scripts.

I would also like to stop at one more interesting project.
lldpd (includes IEEE 802.1ab LLDP) is a daemon for GNU / Linux which includes both reception and transmission via the LLDP (Link Layer Discovery Protocol) and CDP (Cisco Discovery Protocol) protocols.

Install the package:
  $ sudo dpkg -i lldpd_0.4.1-1_i386.deb 

You can now explore the capabilities of the compiled man lldpd program. To add the necessary options when lldpd automatically starts at boot time, edit / etc / default / lldpd.

After starting all the log entries from lldpd, you can see the syslog.

lldpctl is used without any arguments and displays the neighbors found. The following is an example of the output after discovery in a Cisco neighborhood:
  Interface: tun-cisco
  ChassisID: ciscotest (local)
  SysName: ciscotest
  SysDescr:  
    cisco 7206VXR running on
    Cisco Internetwork Operating System Software 
    IOS (tm) 7200 Software (C7200-PM), Version 12.2 (46), RELEASE SOFTWARE (fc1)
    Copyright (c) 1986-2007 by cisco Systems, Inc.
    Compiled Thu 26-Apr-07 21:56 by pwade
  MgmtIP: 172.19.18.2
  Caps: Station (E) 

  PortID: ca: 00: 50: 7b: 00: 00 (MAC)
  PortDescr: FastEthernet0 / 0

    Autoneg: not supported / not enabled
    MAU oper type: unknown (0) 

If CDP, EDP or SONMP were included, then on the next pussy you can see something like this:
  ciscotest # show cdp neighbors 
 Capability Codes: R - Router, T - Trans Bridge, B - Source Route Bridge
                   S - Switch, H - Host, I - IGMP, r - Repeater

 Device ID Local Intrfce Holdtme Capability Platform Port ID
 zoro Fas 0/0 104 Linux tun-cisco 

Well, on this optimistic note, I think, the article can be finished;)

Source: https://habr.com/ru/post/83356/


All Articles