An Engineers Notebook

DNS Policy Load Balancing | Server 2016

By default if we have multiple A records with the same name, the DNS server will round robin i.e alternate through each record returning the value of each DNS record. This is great but if we want more control over balancing the responses to different records we can use DNS Load Balancing Policy to distribute responses in the desired way.

#Add a DNS Zone
Add-DNSServerPrimaryZone -Name "" -ReplicationScope Domain
#Add a Zone Scope called "Scope-Heavy"
Add-DNSServerZoneScope -ZoneName "" -Name "Scope-Heavy"
#Add a  Zone Scope called "Scope-Light"
Add-DNSServerZoneScope -ZoneName "" -Name "Scope-Light"
#Add some A records to each zone, with different IP addresses to which the load will be balanced accordingly
Add-DNSServerResourceRecord -ZoneName "" -A -Name "www" -IPv4Address ""
Add-DNSServerResourceRecord -ZoneName "" -A -Name "www" -IPv4Address "" -ZoneScope "Scope-Light"
Add-DNSServerResourceRecord -ZoneName "" -A -Name "www" -IPv4Address "" -ZoneScope "Scope-Heavy"
#Set a Policy, so that server gets around 9 out of every 11 requests.
Add-DNSServerQueryResolutionPolicy -Name "LB-Policy" -Action ALLOW -Fqdn "EQ,*" -ZoneScope ",1;Scope-Light,1;Scope-Heavy,9" -ZoneName ""
#Check it applied
Get-DNSServerQueryResolutionPolicy -ZoneName ""

Leave a Reply

Your email address will not be published.