Skip to main content

I am looking to see if there is a report or an easy QAPP that can query a device (like a core switch) and return all configured IP addresses (some devices have multiple VRFs).   

We have a few initiatives that this would be a handy set of data (dynamic on demand) for us to have.   

 

Hi Sean,

 

There are two ways this can be solved.

 

  1. Open One-Ip Table in Netbrain and search by your device hostname. This should filter out other entries and show you the IP addresses configured on your device. Only caveat here is, this might NOT work if DNS name resolution isnt configured for your interface ip addresses.
  2. Make a Qapp with parser for command that lists out your IP addresses such as ‘show ip int brief’ and output into a csv. Depending on platform, you might not find a single command that outputs all your IPs, so you might have to get creative using regex and parsing IPs from running configuration.

Hope that helped ! Thanks !!


Thanks Rakesh.   I wish #1 worked, but this effort is so i can gather all configured IPs to create the DNS entries.   

I have been trying #2 and pretty much got it.   Using a mix of IOS and NXOS devices along with vrfs I had to create my own parser.   Additionally I created one for both OS’s for “show standby” and “show hsrp brief” to capture the active VIPs.   

My last task call it is to combine the 4 into a single Qapp or maybe GAPP.   Id like to have a “Configured IP Addresses” QAPP that ingests the map, uses an IF statement to determine OS, then send the correct devices down the correct branch.    My issue is getting the right info to the IF statement.   RegEx and I are not good friends it seems.  


The logic you are working with seems to be the best way to do this. Playing around with if branch should help you execute the parser logic the way you want.

 

and Here’s a small script that can help you start with regex and fetching IPs.

 

import re


text = """
Router# show ip interface brief
Interface IP-Address OK? Method Status Protocol
GigabitEthernet0/1 unassigned YES unset up up
GigabitEthernet0/2 192.168.190.235 YES unset up up
GigabitEthernet0/3 unassigned YES unset up up
GigabitEthernet0/4 192.168.191.2 YES unset up up
TenGigabitEthernet2/1 unassigned YES unset up up
"""
pattern = re.compile(r"\b(?:b0-9]{1,3}\.){3})0-9]{1,3}\b")
result = re.findall(pattern,text)

print(result)

#To see the number of times a pattern repeated in a given text
print(len(result))

---output---
r'192.168.190.235', '192.168.191.2']
2

 


Reply