Infoblox’s global team of threat hunters uncovers a DNS operation with the ability to bypass traditional security measures and control the Great Firewall of China. Read about “Muddling Meerkat” and the many other threat actors discovered by Infoblox Threat Intel here.

API & Integration, DevOps,NetOps,SecOps

Reply

Howto Get ipve4addr in assign_state when creating a host object record:host

New Member
Posts: 1
2453     0

I'm using https://ipam.kpn.org/wapi/v2.9.5/request? to create an host object. In the same call I want to assign the ipv4addr retured by this POST to create a PTR record.

The issue is that I'm not able to assign the ipv4addr to a varaible so I can use it in the next POST.

 

Examples:

The request I fire is:

  • I left the creation of a PTR record out of the example, because that is not my issue 
[
    {
        "method": "STATE:ASSIGN",
        "data": {
            "net": "10.0.2.0/24",
            "hostname": "myhostname"
        }
    },
    {
        "method": "POST",
        "object": "record:host",
        "data": {
            "name": "##STATE:hostname:##",
            "configure_for_dns": false,
            "ipv4addrs": [ 
            	{ 
            		"ipv4addr": "func:nextavailableip:##STATE:net:##",
            		"configure_for_dhcp": false
            	}
            ]
        },
        "args": {
            "_return_fields": "ipv4addrs"
        },
        "assign_state": {
            "created_ip_address": "ipv4addrs"
            
        },
        "enable_substitution": true,
        "discard": true
    },
    {
        "method": "STATE:DISPLAY"
    }
]

The result:

[
    {
        "created_ip_address": [
            {
                "_ref": "record:host_ipv4addr/ZG5zLmhvc3RfYWRkcmVzcyQubm9uX0ROU19ob3N0X3Jvb3QuMi4xNTg4MzIyNjYzMTY3LnNsZGNscjA5OTcuMTAuNDAuMjQzLjIwLg:10.40.243.20/sldclr0997/%20",
                "configure_for_dhcp": false,
                "host": "sldclr0997",
                "ipv4addr": "10.0.2.20"
            }
        ],
        "hostname": "myhostname",
        "net": "10.0.2.0/24"
    }
]

So, I can assign the array ipv4addrs to created_ip_address, but what I want is the assign the ipv4addr from the array to a variable. (assign_state).

 

I expected it to be something like ipv4addrs.ipv4addr or ipv4addrs[0].ipv4addr but that does not work.

 

I hope someone can help me with this.

 

 

Re: Howto Get ipve4addr in assign_state when creating a host object record:host

Adviser
Posts: 181
2453     0

Hi,

 

You can use the next_available_ip function to first get the desired IP address, store it in a variable, and then use it while creating host record and PTR record like below:

 

 

curl -k -u admin:infoblox -H 'content-type:application/json' -X POST "https://grid-master/wapi/v2.10/request" -d'
[
   {
       "method":"STATE:ASSIGN",
       "data":{
            "net":"10.10.10.0/24",
"hostname":"myhostname" } }, { "method":"GET", "object":"network", "data":{ "network":"##STATE:net:##" }, "assign_state":{ "net_ref":"_ref" }, "enable_substitution":true, "discard":true }, { "method":"POST", "object":"##STATE:net_ref:##", "args":{ "_function":"next_available_ip" }, "assign_state":{ "ip_address":"ips[0]" }, "enable_substitution":true, "discard":true }, { "method":"STATE:DISPLAY" } ]'

Use ip_address in subsequent operations.

 

Hope this helps,

Krishna Vasudevan

 

Showing results for 
Search instead for 
Did you mean: 

Recommended for You