Introducing SOC Insights for BloxOne Threat Defense: Boost your SOC efficiency with AI-driven insights to eliminate manual work and accelerate investigation and response times. Read the blog announcement here.

API & Integration, DevOps,NetOps,SecOps

Reply

Single API call to see if server/host/dns name is in use !?

Authority
Posts: 10
1712     0

Team,

 

Is there a single API call to see if a server/host/dns name is in use?

 

Essentially, when needing to provision a new server, I want to do a DNS check (of sorts) to see if a host with that name already exists, but I noticed that host-record, host-alias, cname (and possibly others) etc. are all seperate calls and objects.

 

For instance, I could have a host-alias called "myserver.mydomain.org", but if I were to do a host check against this server, it would return nothing. Similarly I could have a cname called "myserver.mydomain.org" and do a host and/or alias check, and still get nothing back because cnames are yet again different.

 

I'm hoping there is a single API call I can make that would return a match irregardless of the type, but so far I haven't been able to find it or overlooked it.

 

  R.

Re: Single API call to see if server/host/dns name is in use !?

[ Edited ]
Superuser
Posts: 81
1713     0

Hello RdeVries_2,     

 

I think you're looking for something similar to a global search. Here's a sample call for the use-case :

 

# Find matching patterns from the Grid

import requests
import urllib3
import json
from os import system, name


def clear():
    if name == 'nt':
        _ = system('cls')
    else:
        _ = system('clear')


urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

gm_ip = input("\n\nEnter Grid Mater's IP :")
type(gm_ip)
gm_user = input("\nEnter user name :")
type(gm_user)
gm_password = input("\nEnter password :")
type(gm_password)

clear()
fqdn_to_be_searched = input("\nEnter the FQDN to be searched :")
urL = 'https://' + gm_ip + '/wapi/v2.9/search?search_string=' + fqdn_to_be_searched
response = requests.get(urL, auth=(gm_user, gm_password), verify=False)
mid_value = response.content
response_native = json.loads(mid_value)
format_output_data = json.dumps(response_native, indent=1)

if format_output_data == "[]":
    print("No matching patterns found in search")
else:
    print("Found at least one matching entry..\n\n")
    print(format_output_data)

Hope this is helpful!

 

Best regards,

 

Re: Single API call to see if server/host/dns name is in use !?

Authority
Posts: 10
1713     0

Thanks Mohammed. I also found the "allrecords" object which I think can help. This is quite a vast API .. it's like a treasure hunt Smiley Happy

 

Anyway, thanks again for all your help. Much appreciated!

 

   R

Showing results for 
Search instead for 
Did you mean: 

Recommended for You