Friday, December 17, 2010

Generate DNS Import from Solarwinds Orion NCM

It's nice to have entries in your internal DNS for router interface names; it makes stuff like traceroute a whole lot easier to read. Many small-to-mid-size companies use Solarwinds products for network management.

This perl script takes the output that you get from using Solarwinds Network Configuration Manager to run the "show ip interface brief | exclude unassigned" command on a group of Cisco IOS devices and massages it into a format that looks like this:

hostname-interfaceName-interfaceNumber a.b.c.d

where a.b.c.d is the IP address assigned to the interface. This format is suitable for import into many DNS servers.

This code doesn't attempt to abbreviate interface names at all, but it could easily be modified to do so.

I run this on Windows using Cygwin and it works fine. The only caveat is that you need to have the dig command installed.

# takes output from a Solarwinds Orion NCM command script
# that runs "show ip interface brief | exclude unassigned"
# and produces a "hostname IP" output for import into DNS
# this makes traceroutes more readable
# usage: ./ < inputfile.txt
# inputfile.txt will look like this
# when produced by Orion NCM 6.x:
#  (
# Interface   IP-Address      OK? Method Status Protocol   
# Loopback0    YES NVRAM  up     up     
# Vlan163    YES NVRAM  up     up     
# Vlan165    YES NVRAM  up     up  
while (<>){
    chomp; # remove newline characters

# find the line with the hostname in it by searching

# for the "(" character
if ($_=~/\(/) {

    # split that line on the . character
    @hostnameFields = split /\./,$_;
    # hostname is the first element before the first .


# identify lines with "up" in them to remove garbage
if ($_=~/\s+up\s+/) {

    #split the good lines into space-separated fields
    @fields=split  /\s+/,$_;
    #find RFC1918-like addresses only
    if ($fields[1]=~/^10\.|172\.|192\./){
        # skip IP addresses that are already in DNS
          unless (`dig -x $fields[1] +short`) {
          #substitute - for / and : in dns names
          #print in "hostname-interface ipaddr" format
          print "$hostname-$fields[0] $fields[1]\n";    


Anonymous said...

you network guys make everything so hard. ask a DBA to run a select query from the config table next time.

jswan said...

If you could comment with a query that does everything the script does (such as filter for interface state, private addresses, and eliminate illegal characters), that would be quite helpful.

Sagar R said...

I really appreciate information shared above. It’s of great help. If someone want to learn Online (Virtual) instructor lead live training in SOLARWINDS TRAINING, kindly contact us
MaxMunus Offer World Class Virtual Instructor led training on SOLARWINDS TRAINING. We have industry expert trainer. We provide Training Material and Software Support. MaxMunus has successfully conducted 100000+ trainings in India, USA, UK, Australlia, Switzerland, Qatar, Saudi Arabia, Bangladesh, Bahrain and UAE etc.
For Demo Contact us:
Name : Arunkumar U
Email :
Skype id: training_maxmunus
Contact No.-+91-9738507310
Company Website –