Skip to main content

Finding hosts on a downstream leaf switch from a given spine switch

  • April 7, 2026
  • 0 replies
  • 9 views

Christopher
Employee
Forum|alt.badge.img+3

A common network configuration is to have hosts(servers) connected to a leaf switch, which in turn is connected to spine switches, and finally to an upstream L3 switch / gateway.

Host → Leaf Switch (ToR) → Spine Switch(s) → L3 Switch / Gateway(s)

in this scenario, no hosts are directly connected to the spine switch.

Suppose the Network Team wanted to upgrade a Spine switch. Ideally, a leaf switch would not be impacted by a single spine switch going offline. However, the Network Team must still notify application owners for servers on downstream switches with potential impact.

The following NQE query can be used to list all access switches and their hosts that are downstream from a given switch:

import "@fwd/Interfaces/Interface Utilities";

@query
query(deviceName: String) =
foreach device in network.devices
where device.name == deviceName
foreach link in getLinkedInterfaces(device)
let remoteDeviceName = link.remoteDeviceName
foreach remoteDevice in network.devices
where remoteDevice.name == remoteDeviceName
where matches(remoteDeviceName, "*acc*") # Need to filter for only leaf switches
foreach host in remoteDevice.hosts
select {
"Input Device": deviceName,
"Connected Switch": remoteDevice.name,
"Host Name": host.name,
"Host Addresses": host.addresses,
"Host MAC": host.macAddress,
"Host Interfaces": host.interfaces,
"Host Gateway": (foreach gateway in host.gatewayInterfaces select gateway.deviceName)
};

Query results:

 

Note that in the query above, we filter for leaf switches by looking for devices with “acc” in the name. Any filter that helps limit the scope to access switches will work here, such as filtering on Tag.

Note also the “Host Gateway” is listed, which could be used to identify the upstream path for host traffic. The gateway interface or subinterface name could also be listed, if needed.