- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
Adding a PTR record to Infoblox server with a Powershell script
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2020 12:10 AM
Hi all,
new to this forum and fairly new to Infoblox. Have been getting familiar with all things Infoblox over the last few months after many years as a Mainframe specialist.
From eamples I've found in this forum and other places I'm got a Powershell script woirking that adds a Host record to the Infoblox server and the corersponding A record to a Windows 2016 DNS server.
I'm now try to get the script to add a PTR record to the Infoblox server as it will manage the reverse zone lookup while the A record will reside on the Win DNS server.
My code is below and I'm not sure that I have the data defined correctly for the PTR record as when I run it I get this response from the Infoblox server:
Invoke-RestMethod : The remote server returned an error: (400) Bad Request.
At C:\Users\Administrator\documents\powershell scripts\Addhostp.ps1:93 char:24
+ ... $request = Invoke-RestMethod -Uri $uri -Method Post -Body $json -Con ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRe
quest) [Invoke-RestMethod], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Com
mands.InvokeRestMethodCommand
Any help for a newbie appreciated.
process { $apiVersion = 2.10 $uri = "https://$GridServer/wapi/v$apiVersion/record:ptr" if ($PSBoundParameters.ContainsKey('CreateInDNS')) { $dns = $true } else { $dns = $false } # Add the A record to the Windows DNS server Add-DnsServerResourceRecordA -Name $HostName -ZoneName $DNSZone -IPv4Address $IPv4Address $data = @{ ipv4addrs = @( @{ipv4addr = $IPv4Address} ) ptrdname = $HostName comment = $Comment.Trim() view = 'default' configure_for_dns = $dns } $json = $data | ConvertTo-Json # Add the PTR record to the Infoblox server if ($PSCmdlet.ShouldProcess($Hostname, 'Add InfoBlox record host')) { $request = Invoke-RestMethod -Uri $uri -Method Post -Body $json -ContentType 'application/json' -Credential $Credential return $request } }
Solved! Go to Solution.
Re: Adding a PTR record to Infoblox server with a Powershell script
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2020 12:34 AM
Hi,
The body for your PTR record should look something like this.
{ "name":"2.10.10.10.in-addr.arpa", "ptrdname":"server1.info.com", "ipv4addr":"10.10.10.2", "comment":"Test Comment", "view":"default" }
So, your data variable should look like:
$data = @{ name = "2.10.10.10.in-addr.arpa" ptrdname = "server1.info.com" ipv4addr = "10.10.10.2" comment = "Test Comment" view = "default" }
Hope this helps,
Thanks and Regards,
Krishna
Re: Adding a PTR record to Infoblox server with a Powershell script
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2020 05:46 PM
Thaaks very much for your help. I've got the script working now.
Cheers,
Frank
Re: Adding a PTR record to Infoblox server with a Powershell script
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2020 04:10 AM
Just out of curiousity, why add an A/PTR pair when adding a Host record would do the same thing.
Otherwise, when you go to delete the A record, you might leave the PTR as an orphan.
Re: Adding a PTR record to Infoblox server with a Powershell script
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2020 05:10 PM
Yes I agree with you that there is a potential for an orphan record as you mention. However in this case, it was a client requirement, based on their network setup. In their environment, the A record is in fact held on a Windows sServer DNS server, and the reverse lookup zone on the Infoblox server, which is why only the PTR record was to be added there.
Cheers,
Frank
Re: Adding a PTR record to Infoblox server with a Powershell script
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2020 06:47 AM
OK, great! You said the magic words: “Customer requirement”. I run into a lot of people in my job who have never heard of a host record, and are simply unaware of its role.