Reply
Highlighted
Accepted Solution

Automating Network Interface DNS Names

Authority
Posts: 24
4211     0

Hello,

 

I am trying to automate the creation of network device interface names in DNS. I want the interfaces on our network in DNS but it would be pretty much impossible to manage that by hand, which is why we haven't done it yet.

 

After thinking about it, I've come up with the following general workflow to be executed once a month:

 

  1. Get a list of all network IP addresses in our system, from a central source. Since we don't have a real asset management software application yet, I'll just use the Statseeker API to export the list from there
  2. Use the Junos PyEZ stuff to take that list, log into each device, and get a mapping of interfaces to IP addresses. This step is already complete, as I finished writing the script today.
  3. Empty the network.domain.com zone we've created for network devices. This is to ensure we start with a clean slate every time we import and any devices which may have been removed over the last 30 days.
  4. Take the output from that script (which is an infoblox formatted CSV file) and import it into infoblox. I found the script here https://community.infoblox.com/t5/API-Integration/The-definitive-list-of-REST-examples/m-p/1233#M21 which worked beautifully

I still have to do #1 and #3. #1 is irrelevant to this forum and should be a simple API call to our monitoring software. #3 on the other hand is also probably very simple. I just need to clear all A and PTR records from a specific zone. Should be pretty straightforward but I'm just not finding the correct API call to make to do this. 

 

Does anyone have any suggestions, can point me in the right direction, or even have a code snippet that may work here?

 

Thanks!

Re: Automating Network Interface DNS Names

Adviser
Posts: 200
4212     0
Have you looked at Network Insight which can do the discovery and creation of objects in the Grid database for you? There have been some additional improvements in 8.0 that will help with managing those records as well. That would remove a lot of the customization that you’re talking about and it would eliminate some of the additional steps to generate the data and import it.

Re: Automating Network Interface DNS Names

Authority
Posts: 24
4212     0

I haven't looked at that, but I don't think we're likely to be looking to buy any new software.

 

I actually now have #1 done in my list as well. The only part I'm still missing at this point is how to empty A and PTR records from a zone. I'm not sure if the best way is to use the API to run through and grab every record and then iterate through that list with a delete api call, or if there's a way to just say "kill everything in this zone". That's really what I'm looking for. 

Re: Automating Network Interface DNS Names

Moderator BRampling
Moderator
Posts: 87
4212     0

There's no "delete all records" API call. I think your two options are to GET the allrecords object then iterate through and delete the objects or to delete the zone itself then recreate it and it will be empty.

Re: Automating Network Interface DNS Names

Authority
Posts: 24
4212     0

I went with the former, doing a search on all objects that match some criteria and then deleting them all.

 

I actually have a full working script now. Of course this is bound to change and get better over time but for now, check out https://github.com/ipv6freely/junos-dns-scrape/blob/master/junos-dns-scrape.py

 

Thanks for the help!

Showing results for 
Search instead for 
Do you mean 

Recommended for You