Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have a Windows 2008 R2 Enterprise machine (we'll say it's got the computer name set to 'MYSERVER') running the DNS server role - it's not in a domain (System shows it as in a work group called 'WORKGROUP').

I want it to show up in the DNS configuration as 'ns1.mydomain.com' instead of 'MYSERVER' - mydomain.com is an external 'normal' domain, it's not isolated to an intranet or behind a firewall or anything.

I first looked in the DNS configuration after adding the role, but didn't see anything there for changing the Name property.

I tried changing it via WMI, but that didn't work - the MSDN page for the MicrosoftDNS_Server class lists the Name property as readonly which I'm guessing is why the updates weren't taking effect.

Reinstalling the DNS role is fine if that's necessary (if it can't be changed once the role is installed/activated/running), but I don't see how to configure it during role install either.

Thanks!

share|improve this question
    
Can you clarify where you're wanting to change the name? Is the NetBIOS name being used in generated SOA and NS records, or is this somewhere else that you're looking to change it? –  Shane Madden Apr 17 '12 at 17:15
    
why would you not want the name of the server to be NS1 if thats what you are going to have it show up in DNS? –  Jim B Apr 17 '12 at 17:51
    
@ShaneMadden - when I query WMI for the MicrosoftDNS_Server class, there's 1 instance (as you would expect) and it has a Name property that's the NetBIOS name. I can change it (using PowerShell or .NET) and do a Put() call, but it doesn't actually write it back, since requesting the instance again shows the old Name is still present. It does indeed show up in the generated SOA and NS records when a zone is added, so my current parallel effort is trying to modify (or deleted+recreate) those records that are created automatically in new zones. –  James Manning Apr 17 '12 at 21:23
    
@JimB - the machine in question already has other things installed/running that don't handle machine renames well (like SQL Server). Since conceptually there's no reason the DNS server name needs to match, I'm hoping it's something that can be changed. It's only going to be serving specific zones, and it's not included in any of those zones. :) –  James Manning Apr 17 '12 at 21:28

1 Answer 1

It's not the answer I'm looking for, but since I mentioned that the issue was the auto-generated SOA and NS records, I wanted to also include the code I got working for fixing them up after the zone creation.

I didn't modify the question with this since I don't want to confuse what the actual question is, but in case someone else runs across this in the future and there's not a better answer by then, at least this will be a potential workaround for them.

public void FixupResourceRecords()
{
    var resourceRecordClass = new ManagementClass(@"\\localhost\root\MicrosoftDNS:MicrosoftDNS_ResourceRecord");

    var oldServerName = ...;
    var newServerName = ...;

    var search = " " + oldServerName.ToLower() + ".";
    var replace = " " + newServerName.ToLower() + ".";

    // we want the subclasses too (including SOA and NS records)
    var options = new EnumerationOptions() { EnumerateDeep = true };
    var allResourceRecords = resourceRecordClass.GetInstances(options).Cast<ManagementObject>().ToList();

    Console.WriteLine("Checking {0} resource records", allResourceRecords.Count);
    var resourceRecordsToFix = (
        from record in allResourceRecords
        let textVersion = record["TextRepresentation"].ToString().ToLower()
        let replacedVersion = textVersion.Replace(search, replace)
        where replacedVersion != textVersion
        select new
        {
            textVersion,
            replacedVersion,
            record,
        }
    ).ToList();

    Console.WriteLine("Fixing up {0} resource records", resourceRecordsToFix.Count);
    resourceRecordsToFix.ForEach(tuple => 
    {
        // first delete the old one
        tuple.record.Delete();
        resourceRecordClass.InvokeMethod("CreateInstanceFromTextRepresentation", new object[]
            {
                tuple.record["DnsServerName"],
                tuple.record["ContainerName"],
                tuple.replacedVersion,
            });
    });
}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.