Skip to content
Snippets Groups Projects
Select Git revision
  • 82d0b513b0b2b008a41011d2ccf64ed414f2d97f
  • master default protected
  • update_repo_url
  • update-docs
4 results

README.md

Blame
  • user avatar
    Hahn Axel (hahn) authored
    82d0b513
    History

    Infoblox Dns Helperscripts

    Search for hosts and aliases in host objects and names in cname objects in the infoblox dns api and show the result as json.

    Institute for Medical Education; University of Bern

    :page_facing_up: Source: https://git-repo.iml.unibe.ch/open-source/infoblox-dns-helperscripts
    :scroll: License: GNU GPL 3.0

    Requirements

    • Bash
    • curl in $PATH
    • jq in $PATH (optional for coloring json data)

    Installation

    • Execute a git pull of the repository url or download and extract the files somewhere in your filesystem
    • copy inc_ib_config.sh.dist to inc_ib_config.sh
    • edit inc_ib_config.sh and enter hsotname of server with API and the credentials to access it

    Usage

    dns-search.sh

    Search for aliases and hosts.

    ./dns-search.sh
    
    >>>>>>>>>> INFOBLOX DNS SEARCH v1.5
    
    Search for hostnames or aliases in Infoblox API
    It uses dns-api.sh and adds the return field for aliases.
    
    SYNTAX: dns-search.sh [name|alias|cname|ipv4addr] REGEX
    
    EXAMPLES:
    
    (1)
    search for a hostname / A record in host objects
        dns-search.sh name www.example.com
    
    (2)
    search for an alias in host objects - use "alias" as 1st parameter
        dns-search.sh alias alias.example.com
    
    (3)
    search for CNAME objects - use "cname" as 1st parameter
        dns-search.sh cname cname.example.com
    
    (4)
    The search supports regex:
        dns-search.sh name ^mail
        dns-search.sh name "^(mail|www).*example"
    
    (5)
    search for an IP - use "ipv4addr" as 1st parameter
        dns-search.sh ipv4addr .79.30
    
    (6)
    Lazy mode: do not add name or alias or cname to start 4 requests to search 
    in all object types
        dns-search.sh example
    

    You maybe want to start with the lazy mode.

    Here you see how it accesses the api and the returned json data of each request.

    Between the json data are lines starting with a semikolon - these are comments written to STDERR. To hide them add a 2>/dev/null to hide the comments.

    ./dns-search.sh www.iml.unibe.ch
    ;
    ; >>>>>>>>>> INFOBLOX DNS SEARCH v1.5
    ;
    ; search for type : 
    ; search regex    : www.iml.unibe.ch
    ;
    ; === DNS API :: GET /record:host?name~=www.iml.unibe.ch&_return_fields%2B=aliases,ttl
    [
      {
        "_ref": "record:host/REFID:www.iml.unibe.ch/default",
        "aliases": [
          ...
        ],
        "ipv4addrs": [
          {
            "_ref": "record:host_ipv4addr/REFID_2:86.119.35.66/www.iml.unibe.ch/default",
            "configure_for_dhcp": false,
            "host": "www.iml.unibe.ch",
            "ipv4addr": "86.119.35.66"
          }
        ],
        "name": "www.iml.unibe.ch",
        "ttl": 300,
        "use_ttl": false,
        "view": "default"
      }
    ]
    ; === DNS API :: GET /record:host?alias~=www.iml.unibe.ch&_return_fields%2B=aliases,ttl
    []
    ; === DNS API :: GET /record:host?ipv4addr~=www.iml.unibe.ch&_return_fields%2B=aliases,ttl
    []
    ; === DNS API :: GET /record:cname?name~=www.iml.unibe.ch&_return_fields%2B=ttl
    []

    show_ttls.sh

    This helper searches for all host entries that override the default ttl value for the zone objects.

    
    >>>>>>>>>> INFOBLOX DNS HELPER: TTL v1.0
    
    Search for hostnames in Infoblox API and show all hosts that have an
    activated custom ttl value.
    
    It uses dns-api.sh and adds the return field for aliases.
    
    SYNTAX: dns-search.sh REGEX
    
    REGEX  string  search string for a hostname.
                   Use a dot . to scan all hosts you are allowed to access
    

    Example output

    > ./show_ttls.sh .
    ;
    ; >>>>>>>>>> INFOBLOX DNS HELPER TTL v1.0
    ;
    ; === DNS API :: GET /record:host?name~=.&_return_fields%2B=ttl,use_ttl
    host1.example.com
    28800
    host2.example.com
    300

    Between the json data are lines starting with a semikolon - these are comments written to STDERR. To hide them add a 2>/dev/null to hide the comments.

    dns-api.sh

    This is a low level command to access the api. This script is used by dns-search.sh ans show_ttls.sh. But it can be started manually for custom api urls.

    dns-api.sh [METHOD] URL

    Example:

    As an additional information for show_ttl.sh: how to get the default TTL?

    ./dns-api.sh GET '/zone_auth?fqdn=example.com&_return_fields=soa_default_ttl,use_grid_zone_timer'
    ; === DNS API :: GET /zone_auth?fqdn=example.com&_return_fields=soa_default_ttl,use_grid_zone_timer
    [
      {
        "_ref": "zone_auth/RFID:example.com/default",
        "soa_default_ttl": 28800,
        "use_grid_zone_timer": false
      }
    ]