9

I'm wondering if I need to clear some cache or something with the issue I'm having.

I'm trying to remove A records from a DNS Zone and replacing them with a CName record that has the same host name.

Remove-DnsServerResourceRecord -Zonename $line -InputObject $record -Force
Add-DnsServerResourceRecordCName -Zonename $line -Name $hostname -TimeToLive $ttl -HostNameAlias $target

This throws me:

Add-DnsServerResourceRecordCName : Failed to create resource record @ in zone zone.tld on server NS01. At C:\admin\updatettl.ps1:56 char:4 + Add-DnsServerResourceRecordCName -Zonename $line -Name $hostname > -TimeToLive ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ResourceExists: (@:root/Microsoft/...urceRecordCName) > [Add-DnsServerResourceRecordCName] , CimException + FullyQualifiedErrorId : WIN32 9709,Add-DnsServerResourceRecordCName

Any ideas? Thanks

jscott
  • 24,204
  • 8
  • 77
  • 99

2 Answers2

9

Microsofts DNS Server implementation will not allow you to create a CNAME at the zone apex as per RFC 1034 §3.6.2.

The error you receive (9709, DNS_ERROR_CNAME_COLLISION) is a bit cryptic, but you won't (and shouldn't) be able to add it anyways.

On the other hand, placing a CNAME RR at the apex effectively introduces a collision with the NS and SOA records for the zone, at which point the error does make some sense

Mathias R. Jessen
  • 24,907
  • 4
  • 62
  • 95
  • Seems that is correct. When I try to create a CName on @ it throws me this error but when the hostname is set to something like "www" it has no problems with this. Thanks! – Elfar Alfreðsson Jul 31 '14 at 18:31
0

I could successfully create an ALIAS or CNAME using the following syntax as suggested in the Microsoft Documentation

PS C:> Add-DnsServerResourceRecordCName -Name "THE-NEW-ALIAS-NAME" -HostNameAlias "ALREADY-EXISTING-NAME" -ZoneName "example.com" 

Example-Test:

PS C:> Add-DnsServerResourceRecordCName -Name "mylabcn" -HostNameAlias "cslab" -ZoneName "example.com"

mylabcn: The new ALIAS to be created to the existing name:cslab.example.com

Here the -Name parameter is the new ALIAS/CNAME to be created and the -HostNameAlias paramater is the already existing-name to which the new ALIAS name would be created.

Initially I used the above parameters in opposite way, which resulted in the exact above error "9709"

Hope this helps.

sysadmin1138
  • 131,083
  • 18
  • 173
  • 296
RK K
  • 1
  • 1