Are you interested in our Early Access Program (EAP)? This program allows you to preview code, test in your lab and provide feedback prior to General Availability (GA) release of all Infoblox products. If so, please click the link here.

API & Integration, DevOps,NetOps,SecOps

Reply

Lookup IPv4 by MAC Address

Techie
Posts: 3
168     0

Hello,

 

I have been playing around with the WAPI documentation for the past few days.  One thing I have not found an answer for is how to lookup an IPv4 address based on MAC address.  This would be very helpful when it comes to automating the process to register new network devices to fixed addresses.  My goal is to convert the API calls into powershell and run them from a script.

 

I have had some success with simple calls like the following:

$result = Invoke-RestMethod -Method Get -Uri https://$Gridmaster/wapi/v2.7/ipv4address?ip_address=$ipv4Addr -Credential $cred

 

and this one:

$searchIPv4 = Invoke-RestMethod -Method Get -Uri https://$Gridmaster/wapi/v2.7/search?address=$ipv4Addr -Credential $cred

 

 

Any ideas on how I can accomplish this goal through the WAPI interface?

 

 

Re: Lookup IPv4 by MAC Address

Community Manager
Community Manager
Posts: 172
169     0

You will need to specify which fields to return, using the _return_fields option.   For example _return_fields+=mac_address . The MAC address is not included by default.

Re: Lookup IPv4 by MAC Address

Techie
Posts: 3
169     0

Thank you for the response.

 

Do you happen to have an example of what this query would look like?  I'm struggling to find examples and the docuemntation isnt quite clear on how I am supposed to format the call.

 

I think an example of a good call that uses the _return_fields option will help me out alot. 

Re: Lookup IPv4 by MAC Address

Techie
Posts: 3
169     0

I made some good progress.

 

First, I can lookup the IPv4 address based on the network AND MAC address here:

$searchMac = Invoke-RestMethod -Method Get -Uri https://$Gridmaster/wapi/v2.7/ipv4address?network=$ipv4Net"&"mac_address=$mac_addr -Credential $cred

 

Then I can extract the info from here:

$ip = $searchMAC.ip_address

 

Next, I can lookup the MAC address based on the IP address here:

$searchIPv4 = Invoke-RestMethod -Method Get -Uri https://$gridmaster/wapi/v2.7/ipv4address?ip_address=$ip -Credential $cred

 

Then I can extract the info from here:

$macadd = $searchIPv4.mac_address

 

So now the only cleanup is to try and isolate down how to look up an IPv4 address with only a MAC address. 

 

It doesnt appear that mac_address is enough to complete the call on the ipv4address object:

$test = Invoke-RestMethod -Method Get -Uri https://$gridmaster/wapi/v2.7/ipv4address?mac_address=$mac_addr -Credential $cred

 

Is there a more direct way to search the whole IPv4Address object for an IPv4 address by MAC address only?  Otherwise I would have to build a loop and search through every network that we own one at a time to see if there is a match.  While that is possible its not very efficient.

 

 

 

 

 

Showing results for 
Search instead for 
Did you mean: 

Recommended for You

Businesses are investing heavily into securing company resources from cyber-attacks form cybercrimin