top of page

Building an Enterprise Wide WAN MPLS Router IP list with NDNA


Here's how you can utilize the NDNA program to do this:

1. First, put all your L3 IPs (Enterprise Wide) inside the file "enterprise-wide-routers-IPs.txt" in the following folder: /usr/enterprise-wide-routers

These would be the IPs you create using the "create-enterprise-ios-nxos-routers-list.sh.x" script located in the following folder: /usr/enterprise-wide-routers/Create-Enterprise-IP-Lists-Scripts.

e.g.

cd /usr/enterprise-wide-routers/Create-Enterprise-IP-Lists-Scripts

./create-enterprise-ios-nxos-routers-list.sh.x

This will create an IP list of all your L3 Routers across all Data-Centers/All-Sites.

2. Then run the custom enterprise wide router python script, using the command "sh ip bgp summary"

cd /usr/DCDP/bin/python_custom_scripts/enterprise-wide-routers

./enterprise-wide-routers.exe

Once that completes....

You'll have all your configs in the following directory:

/usr/enterprise-wide-routers/configs

Change into this directory

cd /usr/enterprise-wide-routers/configs

3. list the contents of the directory as shown below

root@debian-python:/usr/enterprise-wide-routers/configs# ls 10.112.16.248_2017-07-01 13:28_enterprise-routers_custom.txt 10.40.0.113_2017-07-01 13:28_enterprise-routers_custom.txt 10.112.16.249_2017-07-01 13:28_enterprise-routers_custom.txt 10.40.1.251_2017-07-01 13:28_enterprise-routers_custom.txt 10.112.16.251_2017-07-01 13:28_enterprise-routers_custom.txt 10.40.4.254_2017-07-01 13:28_enterprise-routers_custom.txt 10.112.16.252_2017-07-01 13:28_enterprise-routers_custom.txt 10.40.7.1_2017-07-01 13:28_enterprise-routers_custom.txt 10.120.120.2_2017-07-01 13:28_enterprise-routers_custom.txt 10.40.7.13_2017-07-01 13:28_enterprise-routers_custom.txt 10.126.23.241_2017-07-01 13:28_enterprise-routers_custom.txt 10.40.7.133_2017-07-01 13:28_enterprise-routers_custom.txt 10.126.23.242_2017-07-01 13:28_enterprise-routers_custom.txt 10.44.0.11_2017-07-01 13:28_enterprise-routers_custom.txt 10.126.23.250_2017-07-01 13:28_enterprise-routers_custom.txt 10.44.0.12_2017-07-01 13:28_enterprise-routers_custom.txt 10.127.248.82_2017-07-01 13:28_enterprise-routers_custom.txt 10.44.7.250_2017-07-01 13:28_enterprise-routers_custom.txt 10.129.100.78_2017-07-01 13:28_enterprise-routers_custom.txt 10.48.0.11_2017-07-01 13:28_enterprise-routers_custom.txt

(shortened for brevity)

4. Next, "grep" on the AS number of the MPLS provider. This example shows the Masergy MPLS AS number. Change it to your MPLS provider, e.g. 13979 for AT&T AVPN for example:

root@debian-python:/usr/enterprise-wide-routers/configs# ls *.txt | grep -r 19855

If you have more than one provider AS Number, then you can use egrep (AT&T AVPN example):

root@debian-python:/usr/enterprise-wide-routers/configs# ls *.txt | egrep -r '13979|21302'

Or redundant MPLS providers: (Level 3 and Century Link example)

root@debian-python:/usr/enterprise-wide-routers/configs# ls *.txt | egrep -r '209|3549'

3. Actual final command using the GRASP toolset (See my other blog post on using the GRASP toolset) - This transforms the output to be just the IPs of the devices that have BGP sessions using the AS number 19855.

root@debian-python:/usr/enterprise-wide-routers/configs# ls *.txt | grep -r 19855 | awk {'print $1'} | sed -e 's/_.*//' 10.48.7.1 10.172.7.1 10.129.101.110 10.129.101.102 10.212.7.242 10.129.101.86 10.152.97.249 10.152.97.249 10.95.199.242 10.139.33.13 10.164.7.242 10.152.129.254 10.120.120.2 10.152.0.1 10.75.133.246 10.74.193.3 10.126.23.242 10.160.7.1 10.112.16.248 10.74.7.1 10.40.7.1 10.136.7.242 10.92.7.1 10.36.7.1 10.235.33.242 10.99.1.250 10.53.7.202 10.235.0.1 10.129.100.78

(shortened for brevity)

4. Redirect the output to a file called "MPLS-WAN-Router-IPs.txt" and put into the following folder (/usr/enterprise-wide-routers/Created-IP-Lists)

root@debian-python:/usr/enterprise-wide-routers/configs# ls *.txt | grep -r 19855 | awk {'print $1'} | sed -e 's/_.*//' > /usr/enterprise-wide-routers/Created-IP-Lists/MPLS-WAN-Router-IPs.txt

That's it!

5. Now, you can use this IP list to copy into the main enterprise-router-IP list file that the "enterprise-wide-routers.exe" custom script looks for, and whalla, you can pull custom discovery information and/or program all your MPLS WAN routers using Python automation.

In closing, you can get creative in how you parse the data you pull from the network. For example, let's say this is not an MPLS network. Maybe you want to build a list of all your edge internet facing routers. What you need to do is find something *common* across these devices to parse, that only they will have, e.g. maybe a common subnet?

If there isn't a common subnet or other attribute configured, this is also a good opportunity to implement a consistent IP addressing scheme for your edge routers.

Another option is to create a common loopback interface that only the edge routers have, again, this gives you the opportunity to improve the network and present specific use cases to the customer as to why this is important to facilitating automation.

So, for example, if you create a new loopback5000 that only the edge routers have, you can parse all your edge routers by using grep on "loopback5000" to parse information just on your edge routers.

Stay tuned for more creative ways to use the NDNA program....

Best Regards,

Brett M. Spunt, CCIE No. 12745

Featured Posts
Recent Posts
Archive
Search By Tags
Follow Us
  • Facebook Basic Square
  • Twitter Basic Square
  • Google+ Basic Square
bottom of page