Create Reverse DNS records

Rising Flight 5,216 Reputation points
2021-04-17T11:21:22.817+00:00

Hi Experts

i have few servers which dont have reverse dns records.
for example. server1 and server2 have forward lookup records. i.e server1@Company portal .com pointing to 192.168.5.20, server2@Company portal .com pointing to 192.168.5.21
but these servers dont have reverse dns records.

  1. How do i create reverse DNS records for these servers using powershell.
  2. i have servers list in the below format, how do i import the csv file and create reverse dns records

88791-dnsdns.jpg

Windows for business Windows Client for IT Pros Networking Network connectivity and file sharing
Windows for business Windows Server User experience PowerShell
{count} votes

Accepted answer
  1. Andreas Baumgarten 123.4K Reputation points MVP Volunteer Moderator
    2021-04-17T12:51:29.123+00:00

    Hi @ RisingFlight-7863 ,

    you can give this a try (not tested by myself). Use the script on your own risk.

    $file = "server.csv"
    Import-Csv -Path $file | foreach {
        $name = (($_.IPAddress).Split("."))[3]
        # Modify the -ZoneName to your needs (name of the reverse lookup zone in DNS)
        # Modify the PtrDomainName domain part to your needs (contoso.com)
        Add-DnsServerResourceRecordPtr -Name "$name" -ZoneName "0.168.192.in-addr.arpa" -AllowUpdateAny -TimeToLive 01:00:00 -AgeRecord -PtrDomainName "$_.HostName.contoso.com"
        }
    

    (If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

    Regards
    Andreas Baumgarten

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Rising Flight 5,216 Reputation points
    2021-05-10T21:45:13.767+00:00

    will the below script work for me

    95385-i.jpg

    $ServerName = "MyDomainController"   
    $domain = "contoso.com"   
    Import-Csv C:\temp\Records.csv | ForEach-Object {   
    #Def variable   
    $Computer = "$($_.HostName).$domain"   
    $addr = $_.IP -split "\."   
    $rzone = "$($addr[1]).$($addr[0]).in-addr.arpa"   
    #write-host $rzone  
    #Create Dns entries   
    dnscmd $Servername /recordadd $domain "$($_.HostName)" A "$($_.IPAddress)"   
    #Create New Reverse Zone if zone already exist, system return a normal error   
    #dnscmd $Servername /zoneadd $rzone /primary   
    #Create reverse DNS   
    dnscmd $Servername /recordadd $rzone "$($addr[3]).$($addr[2])" PTR $HostName  
    }  
    

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.