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

Setting Up FTP on CentOS 5.3

Install VSFTPD yum -y install vsftpd   Configure: vim /etc/vsftpd/vsftpd.conf ------------------- anonymous_enable=NO // line 12:…

CCIE Exam Day Overview

1. Network Principles 2. Layer 2 Technologies: LAN switching & WAN Circuits, layer 2 multicast…

PowerShell: Windows Session Memory Usage Watcher

# windowsSessionWatcher.ps1 $serverNames=@( 'IRV-RDS01.domain1.net', 'LAX-RDS02.domain2.com ) $thresholdMemoryUsagePercent=30 $thresholdMemoryGb=20 $domainCreds=@( @{domain='domain1.ad';username='domain1\sysadmin';password=$env:pass1} @{domain='domain2.com';username='domain2\sysadmin';password=$env:pass2} ) # Email relay…