Windows Server 2016

Windows Server 2016 DNS Policy Deny Subnet Access to Zone

Let's take a look at how to us Windows Server 2016 DNS Policy Deny Subnet Access to Zone and filter name resolution traffic based on client subnet

In the previous post,ย Controlling Home Lab DNS Resolution with Windows Server 2016, we looked briefly at the benefits of running Windows Server 2016 DNS server in a home lab environment and why you would want to do that. ย Looking a bit further, with the new DNS Policy that is available in Windows Server 2016 DNS Server, we can do some really interesting things to control name resolution in an environment. ย One of the interesting things to me at first glance was the ability to control which network objects can run queries against your DNS server as well as which zones they have access to. ย Let’s take a look a how to topic –ย Windows Server 2016 DNS Policy Deny Subnet Access to Zone and how we can easily accomplish this with the new DNS policy objects.

Windows Server 2016 DNS Policy Deny Subnet Access to Zone

In the previous post it was mentioned about the various use cases that you can apply DNS level policies. ย Among those including policiesย to ensure high availability, traffic management, but the one that caught my eye wasย filtering. ย So we can filter DNS queries based on certain criteria.

A use case that came to mind for me was filtering traffic from a high riskย subnet, such as a DMZ subnet range. ย Most of the examples in Technet show filtering for reasons such as malware infection, etc and blocking these subnets entirely. ย However, I wanted to do something more interesting – block only traffic from a risky subnet to a certain zone.

If I have a DMZ subnet that I want to allow to utilize an internal DNS server for certain records, but not see an entire internal zone that houses other resources that we do not want the DMZ range to have access to. ย Or I may only want to use the DNS server for recursive queries and block any internal queries, can we do that with DNS policy? ย Yes.

Creating the Policy

Creating DNS Policy in Windows Server 2016 can only be done with Powershell. ย There is no way in the DNS management console to do this as far as I have found. ย There are a couple of new powershell commandlets for Windows Server 2016 DNS Policy that we are interested in.

The first thing we have to do with Powershell is define ourย ClientSubnet that we want to identify for filtering. ย We can do that with theย add-dnsserverclientsubnet commandlet. ย The following commandlet is intuitive – basically we define the name and the IP range for the clientsubnet parameter.

add-dnsserverclientsubnet -Name "DMZ" -IPv4Subnet 192.168.99.0/24 -Passthru

win16dnspol01

After adding the clientsubnet, we can now define the policy we want to invoke. ย I have an internal DNS scope calledย cloud.local housing internal records. ย I want to filter any queries coming from the DMZ range defined above from being able to pull name resolution for the cloud.local scope. ย To do that, we create the policy using theย add-dnsserverqueryresolutionpolicy commandlet. ย We name the policy, define the zonename that we want to deny access to,

add-DnsServerQueryResolutionPolicy -Name "BlockDMZfromInternalScope" -ZoneName "cloud.local" -Action DENY -ClientSubnet "eq,DMZ" -PassThru

win16dnspol02

Testing

Now the policy is in place, let’s look at the behavior from a “DMZ” client. ย If I run an nslookup now we see the following:

win16dnspol03

We see above, we now get aย Query refused when trying to perform nslookup on our internal domain. ย Also, notice in pinging a known host in the cloud.local domain, we don’t get an IP address, we only get aย could not find host reply.

DENY vs IGNORE

I was curious about the behavior of a DENY policy vs an IGNORE policy. ย We easily see the difference in the nslookup reply. ย The IGNORE action drops the request. ย So on the client side, you see a timeout.

win16dnspol04

Removing Policy

If you want to remove the policy you put in place, you first have to remove the policy and then the subnet if you wish to remove it also. ย You can’t delete the subnet before the policy as you will receive an error.

Remove Policy

For a zone policy that we used above, you use theย remove-DnsServerQueryResolutionPolicy commandlet.

remove-dnsserverqueryresolutionpolicy -Name "BlockDMZfromInternalScope" -ZoneName "cloud.local"

Then, to remove theย clientsubnet you use theย remove-DnsServerClientSubnet commandlet like so:

remove-dnsserverclientsubnet -Name "DMZ"

Thoughts

With the new DNS policy functionality we can effectively use Windows Server 2016 DNS Policy Deny Subnet Access to Zone for this use case and many others that can be thought up. ย This includes altering DNS responses based on time of day, client subnet, zone, high availability, and others. ย The policy features with Windows Server 2016 DNS really add a new dimension inย controlling DNS in the enterprise.

Subscribe to VirtualizationHowto via Email ๐Ÿ””

Enter your email address to subscribe to this blog and receive notifications of new posts by email.



Brandon Lee

Brandon Lee is the Senior Writer, Engineer and owner at Virtualizationhowto.com, and a 7-time VMware vExpert, with over two decades of experience in Information Technology. Having worked for numerous Fortune 500 companies as well as in various industries, He has extensive experience in various IT segments and is a strong advocate for open source technologies. Brandon holds many industry certifications, loves the outdoors and spending time with family. Also, he goes through the effort of testing and troubleshooting issues, so you don't have to.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.