How To Set Cname In Dns
Every bit part of a simple Disaster Recovery strategy, we tin use DNS aliases, CNames, to point clients at the currently live service. It seemed similar a simple job to apply PowerShell to script the update of the CName from 1 server to another. Unfortunately, that wasn't the instance, every bit much searching didn't reveal a simple method to do that update. Still, the solution is simple.
To begin with you volition need admission to the DNSServer module. This contains a range of cmdlets, both for managing a DNS server itself and as well its records.
We'll need ii cmdlets to accomplish our objective. Firstly, Add-DnsServerResourceRecordCName which tin be used to add any record type to an existing DNS server and zone. For instance:
Add-DnsServerResourceRecordCName -ComputerName w16-dc01 -ZoneName w16.local -Name LiveSQL -HostNameAlias w16-sql01.w16.local
The –ComputerName parameter specifies the DNS server nosotros'd similar to create the record on. If omitted, information technology assumes the current server is a DNS server. The –ZoneName parameter is the zone we'd like to create the record in. Unless you are hosting multiple zones on the same DNS server, this is probable to merely be the current domain name.
The next two parameters are fundamental to the task we are completing. –Name is the name of the CName entry we want to create. This will be the value clients are configured with, rather than being hard-coded with a specific server name. The –HostNameAlias is the value for that CName record. This is the parameter nosotros'll be flipping between our two hosts to achieve DR. It is this parameter which is not easily exposed through other cmdlets.
Y'all can too utilise the more generic Add-DnsServerResourceRecord to attain the same thing, but with the addition of a parameter specifying the tape type to be created.
To remove an existing CName record we'll use Remove-DnsServerResourceRecord. There is no type-specific version of this cmdlet. For example:
Remove-DnsServerResourceRecord -ComputerName w16-dc01 -ZoneName w16.local -RRType CName -Name LiveSQL -Force
The beginning 2 parameters are the aforementioned every bit for Add together-DnsServerResourceRecordCName, the name of the DNS Server and Zone for the record. The –RRType parameter takes an argument for the type of record we desire to delete, in our example, CName.
-Name is, every bit before, the proper name of the record we'd like to delete. Finally, the –Forcefulness parameter suppresses the "are you sure" prompt which will commonly appear. –WhatIf is besides supported if you'd like to test your control earlier using it for existent.
To reach the goal of flipping between sites in the event of a disaster, nosotros tin use these two commands in reverse, first removing the one-time entry earlier adding the new one.
Remember, both Active Directory replication and the DNS fourth dimension to live parameter will filibuster the update of the CName from a customer'south perspective. However, in a disaster, I expect in that location will exist plenty for users to do than but wait for DNS to update.
Be certain to checkout the other cmdlets in the DNSServer module.
How To Set Cname In Dns,
Source: https://viruk67.wordpress.com/2017/11/08/using-powershell-to-update-a-dns-cname/
Posted by: reddywassing.blogspot.com
0 Response to "How To Set Cname In Dns"
Post a Comment