WMI - how to construct a wmi query to find whether a reverse lookup zone is hosted/available in a DNS server?

asked 2021-03-19T17:57:10.84+00:00
tekbyts 1 Reputation point

I have C# code that uses wmi to connect to microsoft DNS servrers to programmatically create/update/delete DNS entries/records. I however am not able to find how to determine or query and tell whether a given reverse lookup zone is hosted in a DNS server or not. Since i am not able to check in advance, I am not able to say why my DNS requests are failing. for example, Is it because the zone is not hosted in the machine i am connecting to? which i can't tell that is the reason the request fails.

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
6,929 questions
{count} votes

1 answer

Sort by: Most helpful
  1. answered 2021-03-22T03:01:03.547+00:00
    Cheong00 3,421 Reputation points

    Well, examples on WMI are more often in VB scripts.

    To query for RDNS Zones, you can start writing function to query normal DNS zones with this example and removing the giant "Select Case" block to modify the zone.

    Now you just need to know RDNS zone names are in format of "3.2.1.in-addr.arpa." for IP block of "1.2.3.0/24", where if the least significant part is "0" it will be omitted, and you're done.

    ======

    Here are also examples for PowerShell if you like, you can see command Get-DnsServerZone return multiple zone names ended with "in-addr.arpa".

    No comments