Quickstart: Install and configure DNS Server on Windows Server
This quickstart shows you how to install and configure a DNS Server on Windows Server. You'll install the DNS Server role to host DNS zone data, forward DNS queries to DNS root hint name servers, or optionally to an upstream name server.
Prerequisites
Before you can install and configure your DNS server, your computer must meet the following prerequisites:
- 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 existing Windows Server server.
Tip
When you install Active Directory Domain Services (AD DS) with the Active Directory Domain Services Installation Wizard, the wizard gives you the option to automatically install and configure a DNS server. The resulting DNS zone is integrated with the AD DS domain namespace. To learn more, see Understanding Active Directory Domain Services Integration.
To install the DNS Server role as a standalone server, perform the following steps:
Here's how to install the DNS Server role using the Install-WindowsFeature command.
Run PowerShell on your computer in an elevated session.
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 listens for requests on all IP address interfaces. You can configure DNS server to listen on a specify interface using the GUI or by using PowerShell.
Here's how to configure the interface used to listen for DNS requests using the Set-DNSServerSetting command.
Run PowerShell on your computer in an elevated session.
Find your computers existing IP address by running the Get-NetIPAddress cmdlet. Make a note of the IP address that you want to use for your DNS server.
Get-NetIPAddress | fl IPAddress,InterfaceAlias
Store the current DNS server setting in a temporary variable, set the ListeningIpAddress property, 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 is unable 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 properties dialog box or by using PowerShell.
Removing all root hints servers isn't supported. Instead, configure your DNS server to not use root hint name server by selecting the Disable recursion server option in the DNS Manager console Advanced tab. Disabling recursion also disables any configured forwarders. Alternatively, clear Use root hints if no forwarders are available in the Forwarders tab.
Here's how to update a DNS root hint name server using the Set-DnsServerRootHint command.
Run PowerShell on your computer in an elevated session.
Find your computer's existing IP address by running the Get-DnsServerRootHint cmdlet. Make a note of the name server that you want to update.
Get-DnsServerRootHint
Store the current DNS server setting in a variable by running the following commands. Replace the placeholder
<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>"} )
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>"
Apply the updated record by running the following commands.
Set-DnsServerRootHint $RootHintServer
To check the updated root hints, run the following command. Notice that the name server has a trailing dot (.).
Get-DnsServerRootHint
Configure forwarders
You can optionally configure a forwarder to resolve DNS address information rather than forwarding
traffic to the DNS root servers. You can add forwarders using the GUI or by using the
Set-DNSServerForwarder
PowerShell cmdlet.
Note
DNS root hints will not be used unless your forwarders fail to respond.
Here's how to install the DNS server role using the Install-WindowsFeature command.
Run PowerShell on your computer in an elevated session.
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 following commands.$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.
Here's how to uninstall the DNS Server role using the Uninstall-WindowsFeature command.
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 of the following:
- For a DNS server that hosts AD DS-integrated zones, these zones are saved or deleted according to their storage type. The zone data isn't deleted unless the DNS server that you uninstall 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 the new zone file.