Block or allow DNS queries on Windows Server 2016+ with DNS policy: Add-DnsServerQueryResolutionPolicy with IGNORE, FQDN, client subnet and QType criteria, EQ/NE syntax, processing order, and Get/Set/Remove commands.
Home › Guides › DNS policy query filters
Last updated 23 November 2026
On Windows Server 2016 and later, a DNS query resolution policy can act as a query filter: the DNS server checks each query against criteria you set (client subnet, transport protocol, IP version, server interface, queried name, query type, time of day) and applies the policy's action. For a block list use -Action IGNORE, which drops the query with no response so the client times out (DENY answers with SERV_FAIL instead). Block a name and everything under it with Add-DnsServerQueryResolutionPolicy -Name "BlockListPolicy" -Action IGNORE -FQDN "EQ,*.contosomalicious.com" -PassThru; block a subnet by creating a client subnet with Add-DnsServerClientSubnet and matching it with -ClientSubnet "EQ,<name>". An allow list is the same thing turned around: IGNORE everything that is NE (not equal to) the allowed names, subnets or query types. Server level policies are evaluated first, apply to every zone on the server and can only DENY or IGNORE. New policies take effect without restarting the DNS server, except on read-only domain controllers.
You can combine these criteria with AND, OR and NOT logic. Criterion names and sample values are from Microsoft's DNS Policies Overview; parameter names are from the Add-DnsServerQueryResolutionPolicy reference.
| Criterion | Parameter | Sample value and meaning |
|---|---|---|
| Client subnet (a predefined client subnet object the query came from) | -ClientSubnet | EQ,Spain,France: the client subnet is Spain or France. NE,Canada,Mexico: any subnet other than Canada and Mexico |
| Transport protocol (UDP or TCP) | -TransportProtocol | EQ,TCP |
| Internet protocol (IPv4 or IPv6) | -InternetProtocol | EQ,IPv6 |
| Server interface IP address that received the query | -ServerInterfaceIP | EQ,10.0.0.1 |
| FQDN of the record in the query (wildcards allowed) | -Fqdn | EQ,*.contoso.com,*.woodgrove.com: the query is for any record ending in contoso.com or woodgrove.com |
| Query type (A, SRV, TXT and so on) | -QType | EQ,TXT,SRV: the query asks for a TXT or an SRV record |
| Time of day the query is received | -TimeOfDay | EQ,10:00-12:00,22:00-23:00: received between 10 AM and noon or between 10 PM and 11 PM |
Criterion syntax is operator, value01, value02, ... ; operator, value03, value04, ... with the operator EQ or NE, at most one of each per criterion. Values after EQ are OR'd; values after NE are AND'd, so a criterion is met when the query matches one of the EQ values and none of the NE values. Several criteria in one policy are combined with -Condition, AND by default or OR.
ALLOW; DENY, respond with SERV_FAIL; IGNORE, don't respond. Microsoft's filter examples all use IGNORE, so the blocked client's query simply times out.-ProcessingOrder sets precedence: higher numbers have lower precedence, and a new policy is added as the lowest precedence unless you say otherwise. Policies of the same level need different processing orders.-Disable to create the policy without enabling it.All examples are Microsoft's, from Use DNS Policy for Applying Filters on DNS Queries. Block every query for a domain suffix (for domains you have identified as malicious, or that break your usage guidelines):
Add-DnsServerQueryResolutionPolicy -Name "BlockListPolicy" -Action IGNORE -FQDN "EQ,*.contosomalicious.com" -PassThru
Block all queries from a subnet, for example one infected by malware that uses your DNS server to reach malicious sites:
Add-DnsServerClientSubnet -Name "MaliciousSubnet06" -IPv4Subnet 172.0.33.0/24 -PassThru Add-DnsServerQueryResolutionPolicy -Name "BlockListPolicyMalicious06" -Action IGNORE -ClientSubnet "EQ,MaliciousSubnet06" -PassThru
Block only the malicious domain, and only from the infected subnet, by combining both criteria (AND is the default condition):
Add-DnsServerQueryResolutionPolicy -Name "BlockListPolicyMalicious06" -Action IGNORE -ClientSubnet "EQ,MaliciousSubnet06" -FQDN "EQ,*.contosomalicious.com" -PassThru
Microsoft's page uses the same policy name for this example as for the previous one; if you create both, give the second its own name (my note, not in the article). Block the ANY query type, which can be abused for amplification attacks:
Add-DnsServerQueryResolutionPolicy -Name "BlockListPolicyQType" -Action IGNORE -QType "EQ,ANY" -PassThru
A client subnet object is a named group of IPv4 and IPv6 subnets, and several policies can refer to the same one.
An allow list is an IGNORE policy with an NE criterion, so the server processes only matching queries. Microsoft's three examples:
Add-DnsServerQueryResolutionPolicy -Name "AllowListPolicyDomain" -Action IGNORE -FQDN "NE,*.contoso.com" -PassThru Add-DnsServerClientSubnet -Name "AllowedSubnet06" -IPv4Subnet 172.0.33.0/24 -PassThru Add-DnsServerQueryResolutionPolicy -Name "AllowListPolicySubnet" -Action IGNORE -ClientSubnet "NE,AllowedSubnet06" -PassThru Add-DnsServerQueryResolutionPolicy -Name "AllowListQType" -Action IGNORE -QType "NE,A,AAAA,MX,NS,SOA" -ServerInterfaceIP "EQ,164.8.1.1" -PassThru
The article describes the first one as allowing only computers in contoso.com and its child domains to query the server. Going by Microsoft's own criteria table, though, the FQDN criterion matches the name being queried, so this policy ignores queries for names outside contoso.com rather than checking which domain the client belongs to; to limit clients, use the client subnet version. The third example is for external customers querying interface 164.8.1.1: only A, AAAA, MX, NS and SOA queries are answered there, so SRV and TXT records used by internal servers aren't served on that interface.
Copy notes: Microsoft's filter article has curly quotes and an en dash before FQDN and ServerInterface in some examples, a space in "NE, AllowedSubnet06", and writes -ServerInterface; the commands above use straight quotes, no space and the parameter name from the cmdlet reference, -ServerInterfaceIP. The DNS Policies Overview has the same kind of slip: its block-a-domain example says treyresearch.net in the text but uses *.treyresearch.com in the command.
Get-DnsServerQueryResolutionPolicy | Format-List * Get-DnsServerQueryResolutionPolicy -ZoneName "contoso.com" | Format-List * Set-DnsServerQueryResolutionPolicy -Name "PolicyMalicious" -InternetProtocol "eq,IPv4" -PassThru | Format-List * Remove-DnsServerQueryResolutionPolicy -Name "DropPolicy" -PassThru
Without -ZoneName, Get-DnsServerQueryResolutionPolicy returns the server level policies; the output shows Action, Criteria, IsEnabled, Level, Name and ProcessingOrder for each. Set-DnsServerQueryResolutionPolicy changes an existing policy (Microsoft's example adds an IPv4 criterion); if you set a processing order equal to another policy's, the server renumbers the existing policies. Remove-DnsServerQueryResolutionPolicy asks for confirmation unless you add -Force, and the server adjusts the processing order of the remaining policies. To clear every zone level policy from a zone, Microsoft pipes Get into Remove: Get-DnsServerQueryResolutionPolicy -ZoneName "contoso.com" | Remove-DnsServerQueryResolutionPolicy -ZoneName "contoso.com" -Force -PassThru.
-ServerInterfaceIP.Not covered in Microsoft's article: how to log or trace which policy matched a given query. Policies are also how Windows DNS limits recursion to internal clients (recursion scopes, see our DNS cache snooping guide) and how it serves split-brain answers from zone scopes.
Look up DNS Server events such as 4013 and 7062 in the Windows Event ID Lookup, copy the DNS policy lines from the PowerShell Cheat Sheet, pull domain names out of block lists with the Regex Tester, work out the client subnets to block or allow with the IPv4 Subnet Calculator or IPv6 Subnet Calculator, and identify devices on an infected subnet with the MAC Vendor Lookup. Related guides: DNS server cache snooping and recursion scopes, DNS client timeouts with several DNS servers, forwarders and conditional forwarders and common Windows DNS Server and DHCP Server errors.
Want internal and external clients to get different answers for the same name? See split-brain DNS with DNS policy zone scopes.
Need to block zone transfers rather than queries? See DNS zone transfer policies.
Want ALLOW policies that answer each region from its nearest datacenter? See geo-location DNS policy and load balancing.
Every Windows DNS Server and DHCP Server event and symptom in one place: common Windows DNS Server and DHCP Server errors.
Create a server level query resolution policy: Add-DnsServerQueryResolutionPolicy -Name BlockListPolicy -Action IGNORE -FQDN EQ,*.contosomalicious.com -PassThru. The server drops matching queries with no response, so the client times out.
DENY makes the DNS server respond with SERV_FAIL. IGNORE makes it send no response at all, so the client query times out. Server level policies on incoming queries can only use DENY or IGNORE.
Create a client subnet with Add-DnsServerClientSubnet, for example MaliciousSubnet06 for 172.0.33.0/24, then add a policy with -Action IGNORE -ClientSubnet EQ,MaliciousSubnet06. Add an -FQDN criterion as well to block only certain names from that subnet.
No. Microsoft says new policies apply dynamically without restarting the DNS server. The exception is a read-only domain controller, where the DNS Server service must be restarted to load new policies.
Run Get-DnsServerQueryResolutionPolicy | Format-List * for server level policies, or add -ZoneName for the policies of one zone. The output shows the action, criteria, whether the policy is enabled and its processing order.
Runbooks, checklists and helpdesk templates: IT Admin Packs on Gumroad.