Why every (hardware) box on the planet should support LLDP

Recently, I ran across ladvd, an LLDP packet emitter for Linux-based systems. Essentially, it's a little daemon that sits around looking for active network interfaces, and then starts sending out LLDP and/or CDP packets on those interfaces, thereby telling the switches what's connected to them.

This allows you to do the following:

<swstorage11>display lldp neighbor list

System Name          Local Interface Chassis ID      Port ID
srvkvm12.master.dns  GE1/0/15        0025-90d4-259a  p255p1
srvkvm11.master.dns  GE1/0/16        0025-90d4-25b2  p255p1
srvkvm13.master.dns  GE1/0/17        0025-90d4-2546  p255p2
srvkvm14.master.dns  GE1/0/18        0025-90d4-2580  p255p2
swbb01               XGE1/0/1        a45d-364b-cd00  26
srvkvm13.master.dns  XGE1/0/5        0025-90d4-2546  p1p2
srvkvm14.master.dns  XGE1/0/6        0025-90d4-2580  p1p2
srvkvm11.master.dns  XGE1/0/7        0025-90d4-25b2  p1p2
srvkvm12.master.dns  XGE1/0/8        0025-90d4-259a  p1p2
srvkvm03.master.dns  XGE1/0/9        0015-17e0-78cd  eth6
srvkvm02.master.dns  XGE1/0/10       90e2-ba06-1a28  eth6
srvkvm01.master.dns  XGE1/0/11       90e2-ba0b-4348  eth6
srvopenattic02.maste XGE1/0/12       0025-9049-a825  eth4
srvopenattic01.maste XGE1/0/13       0025-9049-a65d  eth4
swstorage12          XGE1/0/14       b8af-6737-0838  Ten-GigabitEthernet1/0/14

So this is a nice list that tells us exactly which systems are connected to the switch, which port they're on, and which port it is we're connected to on their side.

Checking out details for a certain system, we get this:

<swstorage11>disp lldp neigh interface Ten-GigabitEthernet 1/0/12

LLDP neighbor-information of port 12[Ten-GigabitEthernet1/0/12]:
  Neighbor index   : 1
  Update time      : 25 days,18 hours,23 minutes,42 seconds
  Chassis type     : MAC address
  Chassis ID       : 0025-9049-a825
  Port ID type     : Interface name
  Port ID          : eth4
  Port description : Intel Corporation 82599EB 10-Gigabit SFI/SFP+ Network Connectio
  System name        : srvopenattic02.master.dns
  System description : Debian GNU/Linux 7.0 (wheezy) Linux 3.2.0-4-amd64 #1 SMP Debian 3.2.35-2 x86_64
  System capabilities supported : Bridge,Router
  System capabilities enabled   : Bridge

  Auto-negotiation supported : No
  Auto-negotiation enabled   : Yes
  OperMau                    : speed(0)/duplex(Unknown)

  Maximum frame Size: 1522

This even tells us a lot more about the system, including its OS version, the model of its network card, and for some systems, even the interface's IP address is reported. All in all, this is pretty cool, because you won't have to go looking for a certain system's ports — you can simply ask the switches.

lldpd

While ladvd is already pretty neat when it comes to telling your switches what's going on, the lldpd package is even more powerful as it not only emits LLDP packages, but also processes those it receives. This allows you to figure out which switches (and maybe, other hosts) your host is connected to, simply by running lldpctl:

root@srvopenattic03:~$ lldpctl
-------------------------------------------------------------------------------
LLDP neighbors:
-------------------------------------------------------------------------------
Interface:    eth0, via: LLDP, RID: 2, Time: 9 days, 10:41:15
  Chassis:
    ChassisID:    mac 00:16:35:ed:50:00
    SysName:      swrz01
    SysDescr:     ProCurve J4819A Switch 5308xl, revision E.11.10, ROM E.05.05 (/sw/code/build/alpmo(alp11))
    Capability:   Bridge, on
    Capability:   Router, off
  Port:
    PortID:       local 80
    PortDescr:    D2
    PMD autoneg:  supported: yes, enabled: yes
      Adv:          100Base-TX, HD: yes, FD: yes
      Adv:          1000Base-T, HD: no, FD: yes
      MAU oper type: 1000BaseTFD - Four-pair Category 5 UTP, full duplex mode
-------------------------------------------------------------------------------

Putting it to use

After discovering this, I wanted to use the information I got from the switches to draw a map of the network. Since most of the switches we use are HP ProCurves, I wrote procurvegraph.py that queries exactly that information and spits out a dotfile that graphs them. I'm not going to show that graph here for obvious reasons, but it's a pretty cool way to visualize the network, and all you have to do is install a little daemon.

And of course, when moving to a new office and having to discover which switch ports the various wall outlets are connected to, having a Linux laptop with LLDPd around is an invaluable asset... :)