dxc-technology / Hanlon-Microkernel

A small (in-memory) Microkernel used by the Hanlon server for discovery of new nodes
Other
20 stars 21 forks source link

Support for CDP to discover what cisco port are on #22

Open hh opened 9 years ago

hh commented 9 years ago

This might be useful info to have during bootup, probably not a default option, but I find it interesting.

Device ID
  value:  2960S.vulk.pdx
Addresses
  value:  1.1.1.254
Port ID
  value:  FastEthernet0/24
# wget http://downloads.sourceforge.net/project/cdpr/cdpr/2.4/cdpr-2.4.tgz
# cd cdpr-2.4
# make
 # ./cdpr -d enp3s0f1
cdpr - Cisco Discovery Protocol Reporter
Version 2.4
Copyright (c) 2002-2010 - MonkeyMental.com

Using Device: enp3s0f1
Waiting for CDP advertisement:
(default config is to transmit CDP packets every 60 seconds)
Device ID
  value:  2960S.vulk.pdx
Addresses
  value:  1.1.1.254
Port ID
  value:  FastEthernet0/24
hh commented 9 years ago

https://github.com/vincentbernat/lldpd is another link layer protocol that might be interesting

hh commented 9 years ago

Another approach could be to use tcpdump to decode the Device-ID Port-ID

$ sudo tcpdump -v -s 1500 -c 1 '(ether[12:2]=0x88cc or ether[20:2]=0x2000)' -i enp3s0f1
tcpdump: listening on enp3s0f1, link-type EN10MB (Ethernet), capture size 1500 bytes
22:08:05.598455 CDPv2, ttl: 180s, checksum: 692 (unverified), length 432
        Device-ID (0x01), length: 14 bytes: '2960S.vulk.pdx'
        Version String (0x05), length: 244 bytes: 
          Cisco IOS Software, C2960 Software (C2960-LANLITEK9-M), Version 12.2(55)SE9, RELEASE SOFTWARE (fc1)
          Technical Support: http://www.cisco.com/techsupport
          Copyright (c) 1986-2014 by Cisco Systems, Inc.
          Compiled Mon 03-Mar-14 22:53 by prod_rel_team
        Platform (0x06), length: 19 bytes: 'cisco WS-C2960-24-S'
        Address (0x02), length: 13 bytes: IPv4 (1) 1.1.1.254
        Port-ID (0x03), length: 16 bytes: 'FastEthernet0/24'
        Capability (0x04), length: 4 bytes: (0x00000028): L2 Switch, IGMP snooping
        Protocol-Hello option (0x08), length: 32 bytes: 
        VTP Management Domain (0x09), length: 0 bytes: ''
1 packet captured
135 packets received by filter
0 packets dropped by kernel

From: http://dazdaztech.wordpress.com/2013/05/17/using-tcpdump-to-see-cdp-or-lldp-packets/

hh commented 9 years ago

With LLDP configured on your cisco:

$  sudo tcpdump -vv -i enp3s0f1 -s 1500 -XX -c 1 'ether proto 0x88cc'
tcpdump: listening on enp3s0f1, link-type EN10MB (Ethernet), capture size 1500 bytes
22:27:47.852993 LLDP, length 343
        Chassis ID TLV (1), length 7
          Subtype MAC address (4): 64:a0:e7:7b:39:80 (oui Unknown)
          0x0000:  0464 a0e7 7b39 80
        Port ID TLV (2), length 7
          Subtype Interface Name (5): Fa0/24
          0x0000:  0546 6130 2f32 34
        Time to Live TLV (3), length 2: TTL 120s
          0x0000:  0078
        System Name TLV (5), length 14: 2960S.vulk.pdx
          0x0000:  3239 3630 532e 7675 6c6b 2e70 6478
        System Description TLV (6), length 244
          Cisco IOS Software, C2960 Software (C2960-LANLITEK9-M), Version 12.2(55)SE9, RELEASE SOFTWARE (fc1)\0x0aTechnical Support: http://www.cisco.com/techsupport\0x0aCopyright (c) 1986-2014 by Cisco Systems, Inc.\0x0aCompiled Mon 03-Mar-14 22:53 by prod_rel_team
          0x0000:  4369 7363 6f20 494f 5320 536f 6674 7761
          0x0010:  7265 2c20 4332 3936 3020 536f 6674 7761
          0x0020:  7265 2028 4332 3936 302d 4c41 4e4c 4954
          0x0030:  454b 392d 4d29 2c20 5665 7273 696f 6e20
          0x0040:  3132 2e32 2835 3529 5345 392c 2052 454c
          0x0050:  4541 5345 2053 4f46 5457 4152 4520 2866
          0x0060:  6331 290a 5465 6368 6e69 6361 6c20 5375
          0x0070:  7070 6f72 743a 2068 7474 703a 2f2f 7777
          0x0080:  772e 6369 7363 6f2e 636f 6d2f 7465 6368
          0x0090:  7375 7070 6f72 740a 436f 7079 7269 6768
          0x00a0:  7420 2863 2920 3139 3836 2d32 3031 3420
          0x00b0:  6279 2043 6973 636f 2053 7973 7465 6d73
          0x00c0:  2c20 496e 632e 0a43 6f6d 7069 6c65 6420
          0x00d0:  4d6f 6e20 3033 2d4d 6172 2d31 3420 3232
          0x00e0:  3a35 3320 6279 2070 726f 645f 7265 6c5f
          0x00f0:  7465 616d
        Port Description TLV (4), length 16: FastEthernet0/24
          0x0000:  4661 7374 4574 6865 726e 6574 302f 3234
        System Capabilities TLV (7), length 4
          System  Capabilities [Bridge] (0x0004)
          Enabled Capabilities [Bridge] (0x0004)
          0x0000:  0004 0004
        Management Address TLV (8), length 12
          Management Address length 5, AFI IPv4 (1): 1.1.1.254
          System Port Number Interface Numbering (3): 1
          0x0000:  0501 0101 01fe 0300 0000 0100
        Organization specific TLV (127), length 6: OUI Ethernet bridged (0x0080c2)
          Port VLAN Id Subtype (1)
            port vlan id (PVID): 1
          0x0000:  0080 c201 0001
        Organization specific TLV (127), length 9: OUI IEEE 802.3 Private (0x00120f)
          MAC/PHY configuration/status Subtype (1)
            autonegotiation [supported, enabled] (0x03)
            PMD autoneg capability [10BASE-T hdx, 10BASE-T fdx, 100BASE-TX hdx, 100BASE-TX fdx] (0x6c00)
            MAU type 100BASETX fdx (0x0010)
          0x0000:  0012 0f01 036c 0000 10
        End TLV (0), length 0
jcpowermac commented 9 years ago

I think this would be a great addition to the microkernel facts. I use those tcpdump commands to find server ports often. I would suggest supporting both CDP and LLDP. Also thinking it would be kinda nice if displayed it on the MK itself.

hh commented 9 years ago

That last tcpdump command was for lldp. On Nov 22, 2014 7:59 AM, "Joseph Callen" notifications@github.com wrote:

I think this would be a great addition to the microkernel facts. I use those tcpdump commands to find server ports often. I would suggest supporting both CDP and LLDP. Also thinking it would be kinda nice if displayed it on the MK itself.

— Reply to this email directly or view it on GitHub https://github.com/csc/Hanlon-Microkernel/issues/22#issuecomment-64084756 .

tjmcs commented 8 years ago

should be much easier to add these sorts of facts now that we've switched over to an (Alpine Linux based) Docker Microkernel image...