Reply
Highlighted
Accepted Solution

How to create IPAM host object?

reilersjr
Techie
Posts: 5
12774     0

Maybe I'm just confused on how this is supposed to work?  In the GUI, I can create an IPAM host object on an address that is not enabled for DNS and DHCP is unchecked.  I can name the host 'ricktest' for example.  No FQDN requirement.  I'm working in a network view called IPAM-Data for example.

 

How do I do this same thing via. the WAPI?

 

I've managed to create a fixedipaddress object but that's not what I want as it's reserved in DHCP and we're not using DHCP.

 

I've managed to create a record:host object which seems to be a DNS host only.  It showed up in DNS, but no where in IPAM.

 

What am I missing?  I just want to create an IPAM object. :-)

 

Using v2.2.1

 

Thanks!

Re: How to create IPAM host object?

Adviser
Posts: 43
12775     0

You can create the host record with the property "configure_for_dns" set to false.

 

E.g.

 

curl -k1 -u ibuser -X POST https://[gridmaster]/wapi/v1.4.2/record:host?_return_fields=ipv4addrs -H Content-Type:application/json -d '{"ipv4addrs":[{"ipv4addr":"10.10.10.100","configure_for_dhcp":false}],"name":"somename","configure_for_dns":false}'

 

The above example creates a Host record with both DNS and DHCP disabled (i.e., IPAM record).

 

If you want to use the get next available IP function with this it would look like:

 

curl -k1 -u ibuser -X POST https://[gridmaster]/wapi/v1.4.2/record:host?_return_fields=ipv4addrs -H Content-Type:application/json -d '{"ipv4addrs":[{"ipv4addr":"func:nextavailableip:10.10.10.0/24","configure_for_dhcp":false}],"name":"someothername","configure_for_dns":false}'

 

Note that the above examples will work fine with WAPI v2.2.1.  Just change the version in the URL.

Re: How to create IPAM host object?

reilersjr
Techie
Posts: 5
12775     0

ok, Here is what I attempted:

URL: https://10.78.32.30/wapi/v2.2.1/record:host

 

Body:

{"ipv4addrs":[{"ipv4addr":"func:nextavailableip:10.65.5.0/24,IPAM-Data","configure_for_dhcp":false}],"name":"ricktest3","configure_for_dns":false}

 

Response:

{ "Error": "AdmConDataError: None (IBDataConflictError: IB.Data.Conflict:At least one host address must belong to an existing network if DNS is not configured for this host.)", 
  "code": "Client.Ibap.Data.Conflict", 
  "text": "At least one host address must belong to an existing network if DNS is not configured for this host."
}

 Is there a configuration set incorrectly on the network perhaps?  I've played around with configure_for_dns field and if set to false, this will succeed, but will only create a host record in DNS.  The cooresponding IP will not be configured in the IPAM tab.

Re: How to create IPAM host object?

Adviser
Posts: 43
12775     0

Looks like an error with getting the next available IP from the network or reserving that IP on that network.  It may be a permissions problem.

 

Can you create a host record with the DNS checkbox unchecked on this network through the GUI with the same infoblox user that you are using for the API call?

Re: How to create IPAM host object?

reilersjr
Techie
Posts: 5
12775     0

Yup.  I can create a host record without DNS and without DCHP via the GUI in the IPAM section.  My user account has admin rights.

 

for example:

 

1. Data Management-->IPAM

2. I select the IPAM-Data network view from the dropdown

3. I select the network 10.65.5.0/24

4. I select the IP address 10.65.5.1

5. Under 'Related Objects' I click the + to add a new host

6. I de-select 'Enable in DNS'

7. I type in a name 'ricktest3'

8. Save and Close

 

I now have a new host record ricktest3 at address 10.65.5.1.

 

Thanks for your help in troubleshooting this one.  It's a real head scratcher.

Rick

Re: How to create IPAM host object?

Adviser
Posts: 43
12775     0

 

Just looked at the syntax of your call and there's an added parameter in the next available IP function.

 

Try

 

{"ipv4addrs":[{"ipv4addr":"func:nextavailableip:10.65.5.0/24","configure_for_dhcp":false}],"name":"ricktest4","configure_for_dns":false}

 

if that doesn't work,

 

Try

 

{"ipv4addrs":[{"ipv4addr":"10.66.5.3","configure_for_dhcp":false}],"name":"ricktest5","configure_for_dns":false}

Re: How to create IPAM host object?

reilersjr
Techie
Posts: 5
12775     0
Yes.  That added parameter is specifying the network view.  If I don't specify the network view, the default is assumed and gives me the following error:

 

{ "Error": "AdmConProtoError: 10.65.5.0/24 does not match any unique networks/ranges (ipv4addr)", 
  "code": "Client.Ibap.Proto", 
  "text": "10.65.5.0/24 does not match any unique networks/ranges (ipv4addr)"

Which, makes sense. 

 

If I specify the IP:

{"ipv4addrs":[{"ipv4addr":"10.65.5.4","configure_for_dhcp":false}],"name":"ricktest3","configure_for_dns":false}

 

Then I'm back to this error:

 

{ "Error": "AdmConDataError: None (IBDataConflictError: IB.Data.Conflict:At least one host address must belong to an existing network if DNS is not configured for this host.)", 
  "code": "Client.Ibap.Data.Conflict", 
  "text": "At least one host address must belong to an existing network if DNS is not configured for this host."
}

 

 

Re: How to create IPAM host object?

Adviser
Posts: 43
12775     0

Sorry for the confusion on the network view.  I realized after I hit post that the added property was the network view.

 

I think that the issue is that the host object needs to be created in the same network view as the network view for the network that you are using for get next available IP.

 

Try

 

{"ipv4addrs":[{"ipv4addr":"func:nextavailableip:10.65.5.0/24,IPAM-Data","configure_for_dhcp":false}],"name":"ricktest3","configure_for_dns":false,"view":"default.IPAM-Data"}

 

Note that this assumes that the default DNS view for this network view is "default".  If you have changed the DNS view name, then you'll need to use the DNS view name.network view name.

Re: How to create IPAM host object?

reilersjr
Techie
Posts: 5
12775     0

That was it.  Thanks!  Maybe this could get added to the authoritative examples list? :-)

Re: How to create IPAM host object?

ccrossen
Techie
Posts: 6
12775     0

Is there a way to do this using the Invoke-RestMethod cmdlet in PowerShell?

Re: How to create IPAM host object?

Moderator BRampling
Moderator
Posts: 69
12775     0

Here's an example of creating a host record via Invoke-RestMethod:

 

$niosip = "10.0.0.2"
$niosuser = "admin"
$niospw = "infoblox"

$addr = "172.25.0.18"
$name = "test.infoblox.poc"

$resturl = 'https://' + $niosip + '/wapi/v2.3.1/record:host?_return_fields=ipv4addrs'

$data = '{"ipv4addrs":[{"ipv4addr":"' + $addr + '"}],"name":"' + $name + '"}'

$json = $data | ConvertTo-Json

$cred = New-Object PSCredential $niosuser, ($niospw | ConvertTo-SecureString -AsPlainText -Force)

add-type @"
using System.Net;
using System.Security.Cryptography.X509Certificates;

public class IDontCarePolicy : ICertificatePolicy {
public IDontCarePolicy() {}
public bool CheckValidationResult(
ServicePoint sPoint, X509Certificate cert,
WebRequest wRequest, int certProb) {
return true;
}
}
"@
[System.Net.ServicePointManager]::CertificatePolicy = new-object IDontCarePolicy

$out2 = Invoke-RestMethod -Uri $resturl -Method Post -Credential $cred -Body $data -ContentType 'application/json'

Re: How to create IPAM host object?

Sany
Not applicable
Posts: 0
12775     0

Hi,

Could you please help me to write wapi command for delete a host record create with "configure_for_dns":false?

I used the regular method for delete the host and got some error

Re: How to create IPAM host object?

Sany
Not applicable
Posts: 0
12775     0
Hi, Could you please help me to write wapi command for delete a host record create with "configure_for_dns":false? I used the regular method for delete the host and got some error

Re: How to create IPAM host object?

Adviser
Posts: 95
12775     0

@Sany. Please open a new thread for your request and post the error.

 

 

Showing results for 
Search instead for 
Do you mean 

Recommended for You

Infoblox ActiveTrust and a Deeper Dive Into your DNS Security