Install and configure DNS Server (2024)

  • Article

Applies to: Windows Server 2022, Windows Server 2019, Windows Server 2016

This quickstart shows you how to install and configure a DNS Server on Windows Server. You'llinstall the DNS Server role to host DNS zone data, forward DNS queries to DNS root hint name servers, or optionally to anupstream name server.

Prerequisites

Before you can install and configure your DNS server, your computer must meet the followingprerequisites:

  • A computer running a supported version of Windows Server.
  • A static IP.
  • An account that is a member of the Administrators group, or equivalent.

Installing DNS Server

Installing a Domain Name System (DNS) server involves adding the DNS Server role to an existingWindows Server server.

Tip

When you install Active Directory Domain Services (AD DS) with the Active Directory DomainServices Installation Wizard, the wizard gives you the option to automatically install andconfigure a DNS server. The resulting DNS zone is integrated with the AD DS domain namespace. Tolearn more, seeUnderstanding Active Directory Domain Services Integration.

To install the DNS Server role as a standalone server, perform the following steps:

  • PowerShell
  • GUI

Here's how to install the DNS Server role using theInstall-WindowsFeature command.

  1. Run PowerShell on your computer in an elevated session.

  2. To install the DNS role, run the following command. The installation doesn't require a reboot.

    Install-WindowsFeature -Name DNS

Configuring DNS Server

Now you've installed the DNS Server role, you can configure the server.

Configure interfaces

By default a DNS server will listen for requests on all IP address interfaces. You can configure DNSserver to listen on a specify interface using the GUI or by using PowerShell.

  • PowerShell
  • GUI

Here's how to configure the interface used to listen for DNS requests using theSet-DNSServerSetting command.

  1. Run PowerShell on your computer in an elevated session.

  2. Find your computers existing IP address by running theGet-NetIPAddress cmdlet. Make a note of the IPaddress that you want to use for your DNS server.

    Get-NetIPAddress | fl IPAddress,InterfaceAlias
  3. Store the current DNS server setting in a temporary variable, set the ListeningIpAddressproperty, and apply the new settings by running the following commands. Replace the placeholder<ip_address> with the IP you made a note of earlier.

    $DnsServerSettings = Get-DnsServerSetting -ALL$DnsServerSettings.ListeningIpAddress = @("<ip_address>")Set-DNSServerSetting $DnsServerSettings

Configure root hints

Root hints servers are used to help resolving DNS address information when the DNS server isunable to resolve the query locally from a hosted zone or the DNS server cache. Root hints name servers are populated by default in new installations.

You can edit the list of root name servers if required by navigating to the Root Hints tab of the DNS server propertiesdialog box or by using PowerShell.

Removing all root hints servers isn't supported. Instead configure your DNS server to not use root hintname server by selecting the Disable recursion server option in the DNS Manager consoleAdvanced tab. Disabling recursion also disables any configured forwarders. Alternatively, clearUse root hints if no forwarders are available in the Forwarders tab.

  • PowerShell
  • GUI

Here's how to update a DNS root hint name server using theSet-DnsServerRootHint command.

  1. Run PowerShell on your computer in an elevated session.

  2. Find your computers existing IP address by running theGet-DnsServerRootHint cmdlet. Make a noteof the name server that you want to update.

    Get-DnsServerRootHint
  3. Store the current DNS server setting in a variable by running the following commands. Replace theplaceholder <root_hint_name_server> with the root hint name server you noted earlier.

    $RootHintServer = (Get-DnsServerRootHint | Where-Object {$_.NameServer.RecordData.NameServer -match "<root_hint_name_server>"} )
  4. Set the Ipv4address property in the temporary variable by running the following commands.Replace the placeholder <ip_address> with the updated IP address.

    $RootHintServer.IPAddress[0].RecordData.Ipv4address = "<ip_address>"
  5. Apply the updated record by running the following commands.

    Set-DnsServerRootHint $RootHintServer
  6. To check the updated root hints, run the following command. You'll notice the name server has atrailing dot (.).

    Get-DnsServerRootHint

Configure forwarders

You can optionally configure a forwarder to resolve DNS address information rather than forwardingtraffic to the DNS root servers. You can add forwarders using the GUI or by using theSet-DNSServerForwarder PowerShell cmdlet.

Note

DNS root hints will not be used unless your forwarders fail to respond.

  • PowerShell
  • GUI

Here's how to install the DNS server role using theInstall-WindowsFeature command.

  1. Run PowerShell on your computer in an elevated session.

  2. To configure DNS forwarders, replace the placeholders <ip_forwarder_1> and <ip_forwarder_2>with the IP address of the DNS server to be used as your forwarders. Then, run the followingcommands.

    $Forwarders = "<ip_forwarder_1>","<ip_forwarder_2>"Set-DnsServerForwarder -IPAddress $Forwarders

Removing the DNS Server role

To remove the DNS Server role, perform the following steps.

  • PowerShell
  • GUI

Here's how to uninstall the DNS Server role using theUninstall-WindowsFeature command.

  1. In an elevated PowerShell prompt, run the following command:

    Uninstall-WindowsFeature -Name DNS

Important

When removing the DNS server role service from a Windows Server computer be aware:

  • For a DNS server that hosts AD DS-integrated zones, these zones are saved or deletedaccording to their storage type. The zone data isn't deleted unless the DNS server that youuninstall is the last DNS server hosting that zone.
  • For a DNS server that hosts standard DNS zones, the zone files remain in the%systemroot%\System32\Dns directory, but they aren't reloaded if the DNS server is reinstalled.If you create a new zone with the same name as an old zone, the old zone file is replaced with thenew zone file.

Next steps

Now you've installed and configured a DNS server, here are some articles that might help you to domore.

  • DNS Policies Overview
  • Anycast DNS overview
Install and configure DNS Server (2024)
Top Articles
Latest Posts
Article information

Author: Virgilio Hermann JD

Last Updated:

Views: 5824

Rating: 4 / 5 (41 voted)

Reviews: 88% of readers found this page helpful

Author information

Name: Virgilio Hermann JD

Birthday: 1997-12-21

Address: 6946 Schoen Cove, Sipesshire, MO 55944

Phone: +3763365785260

Job: Accounting Engineer

Hobby: Web surfing, Rafting, Dowsing, Stand-up comedy, Ghost hunting, Swimming, Amateur radio

Introduction: My name is Virgilio Hermann JD, I am a fine, gifted, beautiful, encouraging, kind, talented, zealous person who loves writing and wants to share my knowledge and understanding with you.