DNS verify against DCHP

Welcome Forums General PowerShell Q&A DNS verify against DCHP

This topic contains 6 replies, has 4 voices, and was last updated by

 
Participant
1 year, 9 months ago.

  • Author
    Posts
  • #76938

    Participant
    Topics: 4
    Replies: 23
    Points: 0
    Rank: Member

    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

    Keymaster
    Topics: 13
    Replies: 4872
    Points: 1,811
    Helping HandTeam Member
    Rank: Community Hero

    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

      Participant
      Topics: 4
      Replies: 23
      Points: 0
      Rank: Member

      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

      Keymaster
      Topics: 13
      Replies: 4872
      Points: 1,811
      Helping HandTeam Member
      Rank: Community Hero

      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

    Participant
    Topics: 18
    Replies: 244
    Points: 108
    Rank: 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

    https://blogs.technet.microsoft.com/heyscriptingguy/2012/08/23/use-powershell-3-0-to-clear-the-client-dns-cache-on-workstations/

    • #76950

      Participant
      Topics: 4
      Replies: 23
      Points: 0
      Rank: Member

      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

    Participant
    Topics: 2
    Replies: 376
    Points: 0
    Rank: Member

    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

The topic ‘DNS verify against DCHP’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort