Windows Servers

Setting Up the DNS Server Role on Windows Server

By NileVPS Team · Published · 5 min read

اقرأ المقال بالعربي

The DNS Server role turns a Windows server into a name server: it can answer queries for zones you host, forward everything else to upstream resolvers, and, on a domain controller, store its zones inside Active Directory. It is a core piece of any Windows domain, and it is also useful on its own for internal names in a lab or a small office network. This guide covers installation, zones and records, forwarders, recursion and the security settings that matter on an internet-facing VPS.

When you need the DNS role

You need it when:

  • You are building an Active Directory domain. AD relies on DNS SRV records to locate domain controllers, and the DC promotion wizard installs DNS by default.
  • You want internal names such as files.corp.local or app.lab.internal that should not exist in public DNS.
  • You want a local caching resolver for machines on a private network.

You usually do not need it to host your public website's domain. Public zones are normally kept at your registrar or a managed DNS provider, which offers multiple geographically separate name servers. If DNS itself is new to you, start with our explainer on how DNS works.

Installing the role

Install-WindowsFeature DNS -IncludeManagementTools

Before installing, give the server a static IP address and point its own DNS client setting to itself (or to 127.0.0.1) after installation. The management console is dnsmgmt.msc, and the PowerShell module is DnsServer.

Zones and records

A zone is the part of the namespace that this server is authoritative for. The main types:

Zone typePurpose
PrimaryThe writable master copy of the zone
SecondaryA read-only copy transferred from a primary
StubHolds only the NS records of another zone, to find its name servers
Active Directory-integratedA primary zone stored in AD and replicated to other DCs
Reverse lookupMaps IP addresses to names (PTR records)

Create a standalone primary zone stored in a file:

Add-DnsServerPrimaryZone -Name "corp.internal" -ZoneFile "corp.internal.dns"

On a domain controller, prefer an AD-integrated zone with secure dynamic updates:

Add-DnsServerPrimaryZone -Name "corp.internal" -ReplicationScope "Domain" -DynamicUpdate Secure

Add common records:

Add-DnsServerResourceRecordA     -ZoneName "corp.internal" -Name "files" -IPv4Address "10.0.0.20"
Add-DnsServerResourceRecordCName -ZoneName "corp.internal" -Name "intranet" -HostNameAlias "files.corp.internal"
Add-DnsServerResourceRecordMX    -ZoneName "corp.internal" -Name "." -MailExchange "mail.corp.internal" -Preference 10

Create a reverse zone for a private subnet so tools can resolve IPs back to names:

Add-DnsServerPrimaryZone -NetworkId "10.0.0.0/24" -ZoneFile "0.0.10.in-addr.arpa.dns"

Choose internal zone names carefully. Use a subdomain of a domain you own (such as corp.example.com) or a reserved suffix such as .internal, rather than inventing a top-level domain that might later become public.

Forwarders and root hints

When the server receives a query for a name it is not authoritative for, it either uses root hints to walk the DNS hierarchy itself or sends the query to forwarders. Forwarders are simpler to reason about and usually faster:

Add-DnsServerForwarder -IPAddress 1.1.1.1, 9.9.9.9
Get-DnsServerForwarder

For a partner network or a second internal domain, a conditional forwarder sends only that domain's queries to specific servers:

Add-DnsServerConditionalForwarderZone -Name "partner.internal" -MasterServers 10.10.0.53

Recursion and the open resolver problem

A DNS server that answers recursive queries for anyone on the internet is an open resolver, and attackers abuse open resolvers to amplify DDoS traffic. On a VPS with a public IP this matters a lot.

  • If the server only hosts authoritative zones for the public, disable recursion: Set-DnsServerRecursion -Enable $false.
  • If it resolves names for your own machines, keep recursion on but allow port 53 only from your private network or VPN range.

In both cases, restrict inbound UDP and TCP port 53 in the Windows Firewall and in the cloud firewall so only intended clients can reach it.

Zone transfers and scavenging

By default, zone transfers should be limited to the name servers you list. Check the Zone Transfers tab in the zone properties, or set it with PowerShell:

Set-DnsServerPrimaryZone -Name "corp.internal" -SecureSecondaries TransferToZoneNameServer

In domains with dynamic updates, stale records build up as machines are renamed or removed. Enable aging and scavenging at both the server and zone level so old dynamic records are cleaned automatically, but leave static records untouched.

Troubleshooting

Useful commands, from the server or a client:

Resolve-DnsName files.corp.internal -Server 10.0.0.10
Resolve-DnsName example.com -Server 10.0.0.10 -Type MX
Clear-DnsServerCache
Get-DnsServerStatistics

nslookup works too, and the DNS Server log in Event Viewer (Applications and Services Logs) records zone loading problems and transfer errors. For deep investigation, enable debug logging in the server properties temporarily, since it grows quickly.

Quick checklist

  • Static IP on the DNS server, and the server points to itself for DNS.
  • AD-integrated zones with secure dynamic updates on domain controllers.
  • At least two DNS servers for any domain, so one reboot does not break name resolution.
  • Forwarders configured and tested.
  • Recursion limited to trusted clients; port 53 closed to the world.
  • Zone transfers restricted; scavenging enabled where dynamic updates are used.

If you are planning a domain, our guide on promoting a domain controller covers the step where DNS is usually installed.

FAQ

Can I host my public website's DNS on a Windows VPS?

It is technically possible, but you need at least two name servers on separate networks, careful security and constant availability. For most sites, registrar or managed DNS is more reliable, with the Windows DNS role kept for internal names.

Why should a domain controller point to itself for DNS?

Domain members and the DC itself find Active Directory services through SRV records in DNS. If the DC uses a public resolver, those records are not found, and logons, replication and Group Policy start failing.

Should I use forwarders or root hints?

Forwarders are simpler and usually faster, because the upstream resolver already caches popular names. Root hints remain as a fallback if all forwarders fail, so keeping both is a reasonable default.

Related guides