Audit our DNS configuration on Arista Devices and Cisco Devices - Would like to be able to combine the script as a single check, and started it (Second Code Script), but it’s not working yet, I need a little tutoring.
/**
* @intent Audit DNS Configuration on Arista
* @description Searches through the running configuration for a pattern match.
*/
DNS_Standard = d"name-server 1.7.7.7 & 1.7.7.8", "dns domain net.xyz.com ", "ip domain lookup source-interface Loopback0"];
AristaPatternDNS =
```
ip domain lookup source-interface Loopback0
dns domain net.xyz.com
ip name-server vrf default {ipv4Address}
ip name-server vrf default {ipv4Address}
```;
/* Select a list of devices by vendor */
foreach device in network.devices
where device.platform.vendor == Vendor.ARISTA || device.platform.os == OS.ARISTA_EOS
let outputs = device.outputs
foreach command in outputs.commands
where command.commandType == CommandType.CONFIG
let response = command.response
/* parse out the pattern defined above from the response of the CONFIG command type. */
let config = parseConfigBlocks(OS.ARISTA_EOS, response)
foreach match in blockMatches(config, AristaPatternDNS)
/* Display the results */
select {
Device: device.name,
Model: device.platform.os,
Pattern: DNS_Standard,
matchedBlocks: match.blocks
}
Here is the start of something that might work in the future - If someone can figure out how to duplicate the above for multiple Vendors:
MULTIPLE VENDOR “IDEA”
/** Same as ver1 but with an Import DNS_HOSTS from NetworVars/DNS_Servers File - **/
/** Want to be able to get a single DEVICE OUTPUT, why am I getting doubles???? **/
/** **//** **//** **//** **//** **//** **//** **//** **//** **//** **/
DNS_Standard = t"name-server 1.7.7.7 & 1.7.7.8", "dns domain net.xyz.com ", "ip domain lookup source-interface Loopback0"];
foreach Device in network.devices
let OS =
if Device.platform.os == OS.ARISTA_EOS then OS.ARISTA_EOS
else if Device.platform.os == OS.IOS_XE then OS.IOS_XE
else if Device.platform.os == OS.IOS then OS.IOS
else if Device.platform.os == OS.NXOS then OS.NXOS
else OS.UNKNOWN
let Pattern =
if Device.platform.os == OS.ARISTA_EOS then ARISTA_EOS_CONF
else if Device.platform.os == OS.IOS_XE then CISCO_IOS_XE_CONF
else if Device.platform.os == OS.IOS then CISCO_IOS_CONF
else UNKNOWN_CONF
let OUTPUT = Device.outputs
foreach Config in OUTPUT.commands
where Config.commandType == CommandType.CONFIG
let Config = parseConfigBlocks(OS, Config.response)
foreach Match in blockMatches_alpha1(Config, Pattern)
let PATTERN_MATCH = hasBlockMatch_alpha1(Config, Pattern)
let CONFIGURED_SERVERS = SMatch.data.IP1, Match.data.IP2]
let MISSING_IPS = DNS_HOSTS - CONFIGURED_SERVERS
let CONFIGURED_UNSUPPORTED_IPS = CONFIGURED_SERVERS - DNS_HOSTS
select {
Device: Device.name,
Platform: Device.platform.os,
RUNNING_CONFIG: Match.blocks,
DNS_STANDARD: DNS_Standard,
UNSPPORTED_IPS: CONFIGURED_UNSUPPORTED_IPS,
Match: PATTERN_MATCH
}