The sight of a Sysadmin holding a flashlight to trace individual cables in a “spaghetti” server rack is all too familiar. If labels are peeling off or incorrectly marked, finding which switch port a server is connected to can be a nightmare. This is where lldpd becomes your best friend, allowing you to “see through” your network infrastructure without ever leaving your chair.
Stop Wasting Time on Manual Cable Tracing
In large-scale Data Centers, understanding the Physical Topology is mandatory. Usually, we rely on risky manual methods:
- Labeling: Prone to errors after several rounds of maintenance or cable replacements.
- Checking MAC tables on the Switch: You have to log into the switch, find the server’s MAC, and then check the port. This is far too cumbersome if you have hundreds of servers.
- Automated Protocols: Devices automatically “greet” each other and share information. This is the most professional approach.
Why Choose LLDP Over CDP or SNMP?
Every protocol has its pros and cons, but LLDP is becoming the dominant standard.
CDP (Cisco Discovery Protocol) is proprietary to Cisco. If your infrastructure is a mixed-vendor environment consisting of Dell, HP, and Juniper, CDP will quickly show its limitations. Meanwhile, SNMP is quite heavy. To map a network via SNMP, you need a complex Network Management System (NMS) and cannot quickly view results directly from the command line.
LLDP (Link Layer Discovery Protocol) is the IEEE 802.1AB international standard. All major vendors now support it. It operates at Layer 2, meaning even if a server doesn’t have an IP yet, devices can still see each other. lldpd is a lightweight open-source implementation for Linux that supports LLDP and can even emulate other protocols like CDP or EDP.
Practical Benefits of lldpd
Based on real-world operational experience, I highly value lldpd for three reasons:
- Excellent Compatibility: Communicates smoothly with almost any modern switch.
- Friendly CLI: The
lldpclitool has a syntax very similar to the CLI of professional networking equipment. - Highly Detailed Information: You will know the exact switch name, port number, VLAN, and even the capabilities of the remote device.
How to Deploy lldpd on Linux
Below are the steps for Ubuntu/Debian. For CentOS/RHEL, simply replace apt with dnf.
Step 1: Install the package
sudo apt update && sudo apt install lldpd -y
Step 2: Enable the service
Ensure the daemon is running and set to start automatically with the system so that data is always up to date:
sudo systemctl enable --now lldpd
Step 3: Discover neighboring devices
To find out who the server is connected to, run this magic command:
sudo lldpcli show neighbors
The output will clear up all your doubts:
-------------------------------------------------------------------------------
LLDP neighbors:
-------------------------------------------------------------------------------
Interface: eth0, via: LLDP, last updated: 20s
Chassis:
ChassisID: mac 00:25:90:bd:f4:c2
SysName: Core-Switch-Floor-5
SysDescr: Cisco IOS Software, C3750E Software
Capability: Bridge, enabled
Capability: Router, enabled
Port:
PortID: ifname GigabitEthernet1/0/24
PortDescr: Connect-to-Web-Server-01
-------------------------------------------------------------------------------
Looking at this, you know immediately that the server is plugged into port Gi1/0/24 of the Core-Switch-Floor-5. No guessing, no manual tracing.
Optimization and Security Tips
1. Exporting Data for Automation
If you are writing scripts for automation, use the JSON format. It makes data parsing incredibly simple:
sudo lldpcli show neighbors -f json
2. Quick IP Planning After Port Identification
Once you know which VLAN the server is on, the next step is usually assigning an IP. To avoid mistakes when calculating IP ranges (especially for odd subnets like /27 or /29), I often use an IP Subnet Calculator. This tool helps quickly identify the IP range and Broadcast address in seconds.
3. Receive-only Mode
In high-security environments, you might not want your server to reveal its information. To make the server only “listen” without “talking,” edit the /etc/default/lldpd file:
DAEMON_ARGS="-r"
Then restart the service: sudo systemctl restart lldpd.
Troubleshooting When No Devices Are Found
If the show neighbors command returns nothing, check these 3 points:
- Switch Configuration: Many Cisco models have LLDP disabled by default. Enter config mode and type
lldp run. - Interface Status: The cable must be securely plugged in and the link light must be on.
- Firewall: Although rare, ensure the firewall is not blocking EtherType 0x88cc.
Installing lldpd across a 50-node cluster allowed me to redraw the connection map in just 5 minutes. This solution completely eliminates silly errors caused by misplugging cables between redundant nodes. Good luck to all Linux sysadmins—may your work be easier with this tip!

