Cisco CDP on Debian

LLDP をしゃべってもらおうと思ったのだけど、lldpd いれると CDP もしゃべれるようになるとのことなので、とりあえず CDP しゃべってもらうことにした。

参照

  • lldpd
    • ここ見ると書いてあるのだけど、各社のこのへんのプロトコルには一通り対応してるのね。

lldpd also implements CDP (Cisco Discovery Protocol), FDP (Foundry Discovery Protocol), SONMP (Nortel Discovery Protocol) and EDP (Extreme Discovery Protocol). However, recent versions of IOS should support LLDP and most Extreme stuff support LLDP. When a EDP, CDP or SONMP frame is received on a given interface,


使ってみる

  • lldpd インストール
# aptitude search lldpd
# aptitude install lldpd
  • テスト
    • "-c"は cdp の有効化。"-dd" は "stay in foreground and be verbose"
# lldpd -c -dd
priv_ping: monitor ready
lldpd_main: protocol LLDP enabled
lldpd_main: protocol CDPv1 enabled
lldpd_main: protocol CDPv2 enabled
lldpd_main: protocol SONMP disabled
lldpd_main: protocol EDP disabled
lldpd_main: protocol FDP disabled
iface_eth_init: interface eth1 initialized (fd=6)
iface_eth_init: interface eth0 initialized (fd=7)
cdp_decode: unknown CDP/FDP TLV type (2048) received on eth1
cdp_decode: unknown CDP/FDP TLV type (2304) received on eth1
cdp_decode: unknown CDP/FDP TLV type (2560) received on eth1
cdp_decode: unknown CDP/FDP TLV type (2816) received on eth1
cdp_decode: unknown CDP/FDP TLV type (4608) received on eth1
cdp_decode: unknown CDP/FDP TLV type (4864) received on eth1
cdp_decode: unknown CDP/FDP TLV type (5632) received on eth1
cdp_decode: unknown CDP/FDP TLV type (6656) received on eth1
lldpd_decode: Currently, we know 2 different systems
lldpd_decode: Currently, eth1 knows 1 neighbors
    • サーバ側で neighbor を見てみる
$ lldpctl
-------------------------------------------------------------------------------
LLDP neighbors:
-------------------------------------------------------------------------------
Interface:    eth1, via: CDPv2, RID: 1, Time: 0 day, 00:07:30
  Chassis:
    ChassisID:    local 3750.example.jp
    SysName:      3750.example.jp
    SysDescr:     cisco WS-C3750-24TS running on
Cisco IOS Software, C3750 Software (C3750-IPSERVICESK9-M), Version 12.2(52)SE, RELEASE SOFTWARE (fc3)
Copyright (c) 1986-2009 by Cisco Systems, Inc.
Compiled Fri 25-Sep-09 08:32 by sasyamal
    MgmtIP:       192.168.2.1
    Capability:   Bridge, on
    Capability:   Router, on
  Port:
    PortID:       ifname FastEthernet1/0/5
    PortDescr:    FastEthernet1/0/5
-------------------------------------------------------------------------------
    • スイッチ側で neighbor を見てみる。
3750#sh cdp neighbors
Load for five secs: 4%/0%; one minute: 5%; five minutes: 5%
Time source is NTP, 22:36:03.868 JST Tue Mar 1 2011

Capability Codes: R - Router, T - Trans Bridge, B - Source Route Bridge
                  S - Switch, H - Host, I - IGMP, r - Repeater, P - Phone,
                  D - Remote, C - CVTA, M - Two-port Mac Relay

Device ID        Local Intrfce     Holdtme    Capability  Platform  Port ID
linux-host       Fas 1/0/5         104               S    Linux     eth1
1812J            Fas 1/0/2         144             R S I  1812-J    Fas 0
1812J            Fas 1/0/7         175             R S I  1812-J    Fas 6
1812J            Fas 1/0/3         175             R S I  1812-J    Fas 1
3750#
    • もうちょっと詳しく。ここで IP: 172.16.1.16 になってるけど、これ eth1 じゃなくて linux-host の eth0 のサブインタフェース (eth0.901) の IP なんだけど、このアドレス選択ってどうなってるんだろうか…。機器が複数 IP を持つ場合は最小のアドレスをホストの代表アドレスとして使う、とかなのだろうか?
3750#sh cdp neighbors detail
Load for five secs: 5%/0%; one minute: 5%; five minutes: 5%
Time source is NTP, 22:36:54.644 JST Tue Mar 1 2011

-------------------------
Device ID: linux-host
Entry address(es):
  IP address: 172.16.1.16
Platform: Linux,  Capabilities: Switch
Interface: FastEthernet1/0/5,  Port ID (outgoing port): eth1
Holdtime : 114 sec

Version :
Debian GNU/Linux 6.0 (squeeze)
Linux 2.6.32-5-686 i686

advertisement version: 2
Management address(es):

-------------------------
(略)

と、ここまで動いていればOK。あとはちゃんと lldpd を動かす。

  • /etc/init.d/lldpd
DAEMON_ARGS="-c"
  • 起動
# /etc/init.d/lldpd start
  • /var/log/daemon.log にログでるので確認。
$ tail -f /var/log/daemon.log
(略)
Mar  1 22:43:46 linux-host lldpd[14011]: lldpd_main: protocol LLDP enabled
Mar  1 22:43:46 linux-host lldpd[14011]: lldpd_main: protocol CDPv1 enabled
Mar  1 22:43:46 linux-host lldpd[14011]: lldpd_main: protocol CDPv2 enabled
Mar  1 22:43:46 linux-host lldpd[14011]: lldpd_main: protocol SONMP disabled
Mar  1 22:43:46 linux-host lldpd[14011]: lldpd_main: protocol EDP disabled
Mar  1 22:43:46 linux-host lldpd[14011]: lldpd_main: protocol FDP disabled
(略)