Posted On July 9, 2019

PowerShell: Set DNS Servers on Localhost

kimconnect 0 comments
blog.KimConnect.com >> Codes , Networking >> PowerShell: Set DNS Servers on Localhost

Display the current DNS Server Entries

PS C:\Users\KimConnect> Get-DnsClientServerAddress

InterfaceAlias Interface Address ServerAddresses
Index Family
-------------- --------- ------- ---------------
Ethernet 2 6 IPv4 {192.168.1.5, 127.0.0.1}
Ethernet 2 6 IPv6 {::1}
Loopback Pseudo-Interface 1 1 IPv4 {}
Loopback Pseudo-Interface 1 1 IPv6 {fec0:0:0:ffff::1, fec0:0:0:ffff::2, fec0:0:0:ffff::3}
isatap.{65BFBD6D-9E20-4A2... 7 IPv4 {192.168.1.5, 127.0.0.1}
isatap.{65BFBD6D-9E20-4A2... 7 IPv6 {::1}

Note the Interface indexes and run these commands to set them:

$peerDnsServerIp="192.168.1.10"
Set-DnsClientServerAddress -InterfaceIndex 6 -ServerAddresses ($peerDnsServerIp,"127.0.0.1")
Set-DnsClientServerAddress -InterfaceIndex 7 -ServerAddresses ($peerDnsServerIp,"127.0.0.1")

Domain Controllers with DNS integration should have their DNS Client server  address set as their counterparts to avoid “island” effects. Secondary entry should be their loop-back interface – rather than their routable IPs for increased querying efficiency.

The DNS Client service queries the DNS servers in the following order:

  1. The DNS Client queries the first DNS server on the preferred adapter’s list of DNS servers and waits 1 second.

  2. If the DNS Client receives no response, then it queries to the first DNS servers on All Adapters and waits 2 seconds.

  3. If the DNS Client still receives no responses, it queries all DNS servers on All Adapters and waits another 2 seconds.

  4. If no responses again, it queries to all DNS servers on all adapters and waits 4 seconds.

  5. If void condition persists, the DNS client sends queries to all DNS servers on all adapters and waits 8 seconds for a response.

  6. Finally, the DNS client gives up and curses mother nature.

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post

Repair Windows Server 2016 Error 0x800f081f

Run this function in PowerShell as Administrator: function resetWindowsUpdate{ # Source: https://learn.microsoft.com/en-us/troubleshoot/windows-client/installing-updates-features-roles/additional-resources-for-windows-update write-host 'Resetting Windows…

PowerShell: Unjoin Computer From Domain

# unjoinComputerFromDomain.ps1 # Version 0.02 # Notes: # - This function doesn't delete the referenced…

PowerShell: WinSCP Module

$username='bongo' $port=20202 $remoteHost='dev-sftp.kimconnect.net' $privateKey='C:\scripts\keys\testkey.ppk' $remoteRoot='/' $downloadFolder='D:\downloads' $remoteDirectory='/var/www/sftp.kimconnect.net' $currentDirectory=$remoteDirectory $localFolder=(New-Object -ComObject Shell.Application).NameSpace('shell:Downloads').Self.Path $appName='winscp' function includePowerShellWrapper($appName){ #…