Arrow down
arrow down
Arrow down
Arrow down
Arrow down
BLOG | Sep 30, 2025

Create a Reusable Function to Validate Configuration Settings Across Device Types

Network environments often include a wide variety of vendors and OS types. Validating critical configuration settings like NTP servers across all those devices can quickly become complex. This blog shows how to simplify that task by creating a single, exportable NQE function that works for any supported vendor.
Christopher Hendrix
Christopher Hendrix 
Senior Customer Solutions Engineer 
Who should read this post?
  • Network engineers validating device configurations
  • Platform engineers standardizing settings across environments
  • NQE users looking to scale query logic across device types
What is covered in this content?
  • How to write a reusable function to extract NTP server settings
  • Patterns for 12+ OS types, including Cisco, Fortinet, F5, Palo Alto, and Junos
  • How to use export, when, and blockMatches to create scalable logic
  • Best practices for organizing reusable helper functions in your Org Repositor

Why Validate NTP Servers Across Devices

In a typical enterprise environment, NTP server configurations may differ not just between vendors, but even across OS variants within the same vendor. Ensuring that these configurations are correct and standardized is critical for time synchronization, which underpins security, logging, and automation.

Instead of building and maintaining separate validation queries for each device type, Forward Enterprise enables users to create a single exportable function that applies logic conditionally based on the OS.

This approach streamlines configuration auditing and improves operational consistency across diverse infrastructure.

How the NQE Function Works

The getNtpServers(device) function returns a list of NTP servers for any device type. Internally, it routes logic using a when statement to OS-specific functions such as getCiscoNtpServers, getFortinetNtpServers, and so on.

The function checks whether NTP settings are present using platform-specific patterns and logic:

  • Cisco devices: Use running config from device.files.config
  • Fortinet and F5: Require a custom command such as show system ntp or list sys ntp
  • Junos, Palo Alto, Arista, Versa: Use structured pattern matching on config blocks

Each OS-specific helper function returns a list of serverId values extracted from matching blocks.

This modular design allows you to easily add support for new vendors or update patterns without rewriting the entire function.

Real Example: Using the Exported Function

After creating and exporting the getNtpServers(device) function, you can use it in any query by importing it from the Helper Functions folder in your Org Repository:

import "Helper Functions/GET NTP Servers";

foreach device in network.devices
where device.platform.vendor != Vendor.FORWARD_CUSTOM
let ntpServers = getNtpServers(device)
select {
  violation: !isPresent (max(ntpServers)),
  device: device.name,
  vendor: device.platform.vendor,
  OS: device.platform.os,
  "NTPSERVERS": ntpServers
}

This query will show a violation if no NTP servers are present, excluding Forward synthetic devices. The simplicity of the line let ntpServers = getNtpServers(device) demonstrates the power of reusable functions in NQE.

Organizing Helper Functions for Reuse

To maintain a scalable query library, Forward Networks recommends saving commonly used functions in a folder named Helper Functions at the root of your Org Repository.

Functions like getNtpServers, getDnsServers, and getSnmpSettings can then be imported as needed in multiple queries, reducing duplication and enabling faster onboarding for new team members.

Following this structure also ensures consistency and allows teams to quickly adopt updates to centralized logic.

Industry Recognition

Winner of over 20 industry awards, Forward Enterprise is the best-in-class network modeling software that customers trust

Customers are unanimous:
Forward Enterprise is a game-changer

From Fortune 50 institutions to top level federal agencies, users agree that Forward Enterprise is unlike any other network modeling software

Most Recent

Browse all posts

Subscribe to our newsletter

Make sure you don't miss a post by signing up here for our monthly 'Moving Forward' newsletter
Top cross