Setting Up and Configuring DNS (IIS 6.0)
Domain Name System (DNS) is an important part of creating new sites, especially if you host many sites on a single server with one Internet Protocol (IP) address. For more information about DNS and IP addresses, see Configuring Internet Sites and Services.
One tool that can be helpful in managing DNS is the Dnscmd.exe command-line tool that is provided with the Support Tools for Microsoft® Windows® Server 2003, Standard Edition; Microsoft® Windows® Server 2003, Enterprise Edition; and Microsoft® Windows® Server 2003, Datacenter Edition operating systems. You can use Dnscmd.exe to view, manage, and update existing DNS server configurations or to set up and configure new DNS servers on your network. Before you use Dnscmd.exe, decide how best to configure DNS zones for your network, or, if you have a designated DNS administrator for the network, ask him or her which parameters to use. For more information about using Dnscmd.exe, see Server administration using Dnscmd in Help and Support Center for Microsoft® Windows® Server 2003.
Listing 9.1 shows how you can use Dnscmd.exe to set up a DNS zone for contoso.com, create entries for contoso.com and www.contoso.com that point to IP address 10.1.1.1, and then set up a canonical name (CNAME) for www.contoso.com that instructs the DNS server to use the same IP address that is configured for contoso.com.
You must be a member of the Administrators group on the local computer to run scripts and executables. As a security best practice, log on to your computer by using an account that is not in the Administrators group, and then use the runas command to run your script or executable as an administrator. At a command prompt, type runas /profile /User:MyMachine\Administrator cmd to open a command window with administrator rights and then type cscript.exe ScriptName (include the script's full path and any parameters).
Listing 9.1 Sample Script for Setting Up and Configuring DNS
dnscmd PRIMARY /zoneadd contoso.COM /primary /file contoso.COM.dns //sets up the overall zone contoso.COM on the primary name server dnscmd SECONDARY /zoneadd contoso.COM /secondary /file contoso.COM.dns //sets up the zone on the secondary dnscmd PRIMARY /recordadd contoso.COM @ A 22.214.171.124 //sets up the record on the primary server for contoso.COM pointing to the IP 10.1.1.1 dnscmd PRIMARY /recordadd contoso.COM www CNAME contoso.COM //sets up a CNAME record for WWW.contoso.com to point to the same IP as // contoso.COM