Cisco devices don’t warn you before rebooting with unsaved changes. A missed write memory means the running config is lost—and the device reloads with an outdated startup config. That’s how critical updates disappear, outages happen, and incidents get escalated. Manually checking for this drift across hundreds or thousands of devices is tedious and error-prone.
This NQE script checks for differences between the startup and running configurations on Cisco devices. It filters out irrelevant lines (like timestamps or system boot info), compares both configs line by line, and reports any differences as violations.
It also labels:
Use this as a snapshot-based drift detector across your entire Cisco fleet.
Here’s the full NQE query provided by the Forward Networks community:
exceptionsList = [
"Current Configuration ...",
"",
"boot system.*"
];
exceptions(line) =
foreach item in exceptionsList
where hasMatch(line, regex(item))
select line;
flatten(outer) =
foreach list in outer
foreach item in list
select item;
config(device, show) =
foreach command in device.outputs.commands
where command.commandText == show
let response = parseConfigBlocks(device.platform.os, command.response)
let text = (foreach line in response
let lines = if length(line.children) == 0
then [line.text]
else [line.text] + flatten(foreach line1 in line.children
select if length(line1.children) == 0
then [line1.text]
else [line1.text] + flatten(foreach line2 in line1.children
select if length(line2.children) == 0
then [line2.text]
else [line2.text] + flatten(foreach line3 in line2.children
select if length(line3.children) == 0
then [line3.text]
else [line3.text] + flatten(foreach line4 in line3.children
select if length(line4.children) == 0
then [line4.text]
else [""]))))
foreach item in lines
where item not in exceptions(item)
select item)
foreach line in text
select line
;
foreach device in network.devices
let runningConfig = config(device, "show running-config")
let startupConfig = config(device, "show startup-config")
let uncommitted = runningConfig - startupConfig
let removed = startupConfig - runningConfig
select {
violation: runningConfig != startupConfig,
device: device.name,
os: device.platform.os,
uncommitted,
removed
}
The output flags any differences and labels the device with a "violation": true tag if drift is detected. You can use this data for ticket generation, dashboards, or alerting workflows.
Check out the original Forward Networks community post to copy the full script and review usage tips:
Prevent Outages from Uncommitted Configs: Using NQE to Compare Cisco Running and Startup Configs