Skip to main content

Cisco NX-OS static null routes

Find all static null routes on Cisco NX-OS devices​

This query illustrates that text matching patterns may include components such as ipv4Subnet that match specific types of entities, not just strings.

Using patternMatches​

foreach device in network.devices
where device.platform.vendor == Vendor.CISCO &&
device.platform.os == OS.NXOS
let staticRoutes =
(foreach match
in patternMatches(device.files.config, `ip route {prefix:ipv4Subnet} Null0`)
select match.data.prefix)
select { device: device.name,
prefixes: staticRoutes,
violation: length(staticRoutes) > 0
}

Using patternMatch​

foreach device in network.devices
where device.platform.vendor == Vendor.CISCO &&
device.platform.os == OS.NXOS
let staticRoutes =
(foreach line in device.files.config
let match = patternMatch(line.text, `ip route {prefix:ipv4Subnet} Null0`)
where isPresent(match)
select match.prefix)
select { device: device.name,
prefixes: staticRoutes,
violation: length(staticRoutes) > 0
}