OmniSwitch mit Ports und automatisch gesetzten LLDP-Aliasen
|

OmniSwitch: Setting Port Aliases Automatically from LLDP

A typical scenario: an access point has failed, you connect to the switch remotely and want to check which port it was connected to. As long as the device is online, LLDP tells you reliably. Once it is offline, however, the LLDP entry is gone too – and the port is just one of many without a link. Without maintained port descriptions, all that is left is guessing, digging through documentation or sending someone on site.

The solution is simple: the LLDP information has to be saved while the device is still online. That is exactly what the small Python script I present in this article does. It reads the LLDP neighbors of an Alcatel-Lucent Enterprise OmniSwitch and writes meaningful interface aliases into the configuration. If a device fails later, the port still shows what was connected to it.

The Idea

For every port with an active neighbor, LLDP provides, among other things, its system name, its system description and the description of the remote port. From this, a sensible alias can be derived without maintaining every port by hand:

Neighbor Proposed alias
OmniSwitch CORE-SW1, port 1/1/49 UPLINK-CORE-SW1_1_1_49
Access point AP-EG-01, eth0 OAW-AP-EG-01_eth0
Router fritz.box, LAN:3 fritz.box_LAN3

If the neighbor is itself an OmniSwitch, the alias gets the prefix UPLINK-. For an OmniAccess Stellar access point, OAW- is prepended. That way, show interfaces alias shows at a glance where the uplinks are and where the APs are connected.

How the Script Works

The script runs directly in the switch shell and uses only the familiar CLI commands:

  1. show lldp remote-system – reads all LLDP neighbors
  2. show interfaces alias – reads the aliases currently configured
  3. For each port, a new alias is proposed and shown next to the existing one
  4. interface <port> alias "<alias>" – sets the alias if desired

One detail mattered to me: the alias is built from data that the neighbor device sends via LLDP and then ends up in a shell command. In the worst case, a crafted system name could execute arbitrary commands on the switch. That is why the script consistently replaces every character outside A–Z a–z 0–9 . _ - with an underscore.

Requirements

  • OmniSwitch running AOS 8.x with Python 3 on the switch (tested with AOS 8.10R2)
  • LLDP enabled on the relevant ports

I tested the script on an OS6360-P24 running AOS 8.10.105.R02 GA, with OmniAccess Stellar AP1201, AP1221 and AP1431 on AWOS 5.0.4 as neighbors.

Installation and Usage

Copy the script to the switch via SCP, for example to /flash/python/, and run it there. There are three modes:

python3 alias-lldp.py --dry-run   # show proposals only, change nothing
python3 alias-lldp.py             # confirm each port interactively
python3 alias-lldp.py --auto      # apply all proposals without asking

In interactive mode the script asks for each port: y sets the alias, n keeps the port unchanged, a applies this and all remaining ports, s skips the rest.

I recommend always starting with --dry-run. It shows exactly which port would get which alias – and which existing alias would be overwritten.

Important: write memory

The changes are applied to the running configuration only. To make them survive a reboot, save them afterwards as usual with write memory.

Conclusion

The script is deliberately small and has no dependencies. It preserves the knowledge that LLDP only provides during operation permanently in the switch configuration. When a device is unreachable remotely, the port immediately shows what should be connected there – instead of searching old documents or sending someone to check. It makes sense to run the script once after installations and changes so the aliases stay up to date.

The script is available on GitHub under the MIT license: github.com/dgawin/ALE-LLDP-Alias.

Note: This is a personal project and is not affiliated with Alcatel-Lucent Enterprise or my employer SPIE. Use at your own risk – always test with --dry-run before using it in production.

Similar Posts