Find us on social media
DNSWindows ServerNetwork6 min read
Configure DNS server
Install and configure the DNS Server role on Windows Server with zones and records.
Windows Server includes a full-featured DNS server role. Use it to host DNS zones for your domains or as a caching resolver.
Step 1 — Install the DNS Server role
powershell
Install-WindowsFeature DNS -IncludeManagementToolsStep 2 — Verify the service
powershell
Get-Service DNSStep 3 — Create a forward lookup zone
powershell
Add-DnsServerPrimaryZone -Name "mydomain.com" -ZoneFile "mydomain.com.dns"Step 4 — Add DNS records
powershell
# A record (domain to IP)
Add-DnsServerResourceRecordA -ZoneName "mydomain.com" -Name "@" -IPv4Address "YOUR_VPS_IP"
# A record for subdomain
Add-DnsServerResourceRecordA -ZoneName "mydomain.com" -Name "www" -IPv4Address "YOUR_VPS_IP"
Add-DnsServerResourceRecordA -ZoneName "mydomain.com" -Name "api" -IPv4Address "YOUR_VPS_IP"
# CNAME record
Add-DnsServerResourceRecordCName -ZoneName "mydomain.com" -Name "mail" -HostNameAlias "mydomain.com"
# MX record
Add-DnsServerResourceRecordMX -ZoneName "mydomain.com" -Name "." -MailExchange "mail.mydomain.com" -Preference 10
# TXT record (SPF)
Add-DnsServerResourceRecord -ZoneName "mydomain.com" -Name "." -Txt -DescriptiveText "v=spf1 ip4:YOUR_VPS_IP -all"Step 5 — Create a reverse lookup zone
powershell
Add-DnsServerPrimaryZone -NetworkId "YOUR_SUBNET/24" -ZoneFile "reverse.dns"Step 6 — Configure forwarders
Forward queries for unknown domains to public DNS:
powershell
Set-DnsServerForwarder -IPAddress "8.8.8.8", "1.1.1.1"View existing records
powershell
Get-DnsServerResourceRecord -ZoneName "mydomain.com"Remove a record
powershell
Remove-DnsServerResourceRecord -ZoneName "mydomain.com" -Name "old" -RRType A -ForceAllow through firewall
powershell
New-NetFirewallRule -DisplayName "DNS TCP" -Direction Inbound -Protocol TCP -LocalPort 53 -Action Allow
New-NetFirewallRule -DisplayName "DNS UDP" -Direction Inbound -Protocol UDP -LocalPort 53 -Action AllowOpen DNS Manager GUI
powershell
dnsmgmt.mscTip
If you only need DNS for a few domains, consider using your domain registrar's DNS or Cloudflare instead. The Windows DNS role is best suited when you need full control over DNS resolution or are running Active Directory on your Baires Host VPS.
Was this guide helpful?