DNS verify against DCHP

This topic contains 6 replies, has 4 voices, and was last updated by  Max Kozlov 1 week ago.

  • Author
    Posts
  • #76938

    Cory
    Participant

    Not for sure if I am over looking something but I have not been able to find a good way to verify that DNS entries are correct for my computers.
    If anyone has an idea or has already done this and would like to share that would be awesome.

    I have all my computers in a text file from AD that I would like to verify that the DNS forward and reverse Lookup zones are correct based off of the DHCP lease.
    We constant are unable to communicate with computers because DNS is pointing to the wrong address and was hoping for an easier and more proactive way to catch these before they are a problem.

  • #76941

    Don Jones
    Keymaster

    Well... at the risk of sounding snarky, I'd look for the source of the problem and fix that. I mean, you could certainly write a script to check DNS records, I suppose... but _why_ are they wrong? Is DDNS failing at the client or the DNS server? Why are server DHCP leases changing – normally, I'd expect a server to continually renew the same lease – are your DHCP scopes running out of addresses?

    • #76945

      Cory
      Participant

      Wish I could fix the problem, unfortunately that is not possible. The beast is to big to tame atleast until it dies. I have no control over that choice so I am trying to fix what I can.

    • #76948

      Don Jones
      Keymaster

      Sounds like you need a new job. Or at least tell the existing one, "no, we either fix the problem or we don't fix the problem, but you don't pay me to slap band-aids on things. I'm an engineer, not an EMT."

  • #76944

    Simon B
    Participant

    I agree with Don on fixing the issue rather than a sticking plaster approach. But if you want to script it have a look here. I would probably use the bottom one in the comments unless you are in a pure win 8 + environment

    • #76950

      Cory
      Participant

      Thank you will look into it.

      I guess I was just looking more for the script to report back in a xls file or something with the Computername, Reverse Lookup info, Forward lookup info, and DHCP address in the four columns. Maybe I explained it wrong in the original post

  • #76984

    Max Kozlov
    Participant

    while you search for better job you can use something like this 😉

    $leases = Get-DhcpServerv4Lease -ScopeId $scopeid -ComputerName $dhcpserver
    foreach ($lease in $leases) {
      $hostname = $lease.HostName
      $ipAddress = $lease.IPAddress
      $dnsHostNameEntry = [System.Net.Dns]::Resolve($ipaddress)
      $dnsHostAddressEntry = [System.Net.Dns]::Resolve($ipaddress)
      # here you should test for emtiness in $dnsHostNameEntry, $dnsHostAddressEntry - its your homework
      if (($hostname -ne $dnshostnameentry.hostname)) -or ($dnsHostAddressEntry.AddressList.Count -gt 1) -or ( $ipAddress -notin $dnsHostAddressEntry.AddressList ) {
        Big Alert !!!
      }
    }
    

    you should repeat it (with appropriate code corrections of course) for forward and reverse scopes

You must be logged in to reply to this topic.