Skip to content

How to Configure DNS Client Settings with PowerShell Print

  • 0

Windows DNS client settings determine which resolvers a server asks for names. An incorrect resolver can break domain sign-in, application connections and administration even when the network interface and IP gateway are working.

Choose resolvers for the server’s role

For a domain member, use the approved DNS servers that resolve the Active Directory namespace. A public resolver may answer internet names successfully while failing to resolve the domain’s service records. Adding one as an alternate is not a reliable way to fix an internal DNS problem.

Identify every active interface, including VPN and virtual adapters. Select the interface used for the intended traffic. Record whether its DNS addresses currently come from DHCP or static configuration so you can restore the same management model after a test.

Inspect the current settings

Use an elevated PowerShell session and keep a recovery connection available. The interface index is local to the server and can change between machines. Never copy an example index without inspecting your own interfaces.

Get-NetAdapter | Select-Object Name,InterfaceIndex,Status
Get-NetIPConfiguration
Get-DnsClientServerAddress -AddressFamily IPv4

Apply the approved resolver addresses

The following example assigns two documentation-only addresses to interface 12. Replace all three values with your real interface and authorized resolvers. Do not add a resolver you do not operate or trust.

Set-DnsClientServerAddress -InterfaceIndex 12 -ServerAddresses @('192.0.2.10','192.0.2.11')
Get-DnsClientServerAddress -InterfaceIndex 12 -AddressFamily IPv4

Test internal and external resolution separately

Query a known internal host, the domain’s service records and an approved external hostname. Use a specified resolver to distinguish a server-side DNS problem from selection of the wrong client interface. A cached answer can conceal a failed resolver, so compare explicit-server queries with the application’s actual experience.

Resolve-DnsName app01.corp.example -Server 192.0.2.10
Resolve-DnsName -Type SRV _ldap._tcp.dc._msdcs.corp.example -Server 192.0.2.10
Resolve-DnsName www.microsoft.com -Server 192.0.2.10

Diagnose errors before clearing caches

A timeout suggests a resolver or network-path problem; an authoritative name error can mean the record is missing or the wrong namespace is being queried. Compare both configured resolvers. If one is stale or unreachable, investigate it rather than assuming the alternate setting guarantees transparent failover.

Review DNS suffixes and the hostname used by the application when a short name fails but a fully qualified name works. A resolver change does not update a certificate, firewall rule or application connection string. Clearing the client cache can be useful after correcting a stale answer, but it is not a repair for a missing authoritative record.

Restore DHCP-provided DNS or the recorded baseline

If the interface originally received its resolvers through DHCP, return it to that arrangement with ResetServerAddresses. If it was statically configured, restore the exact recorded list instead. Verify domain access and the business application after rollback.

Set-DnsClientServerAddress -InterfaceIndex 12 -ResetServerAddresses

Microsoft reference

Consult the Set-DnsClientServerAddress reference for parameter behaviour and the Resolve-DnsName reference for diagnostic query options.


Was this answer helpful?

« Back