Recipe 13.2. Starting and Stopping the DNS ServerProblemYou want to start or stop the DNS Server. SolutionUsing a graphical user interface
Using a command-line interfaceYou can use the net.exe command to stop or start the DNS Server service on the local machine: > net stop dns > net start dns If you want to stop or start DNS Server remotely, use the sc.exe command: > sc \\<ServerName> stop dns > sc \\<ServerName> start dns Using VBScript' This code restarts the DNS Server on the specified host. ' ------ SCRIPT CONFIGURATION ------ strServer = "<ServerName>" ' e.g., dns1.rallencorp.com ' ------ END CONFIGURATION --------- on error resume next set objDNS = GetObject("winMgmts:\\" & strServer & "\root\MicrosoftDNS") set objDNSServer = objDNS.Get("MicrosoftDNS_Server.Name="".""") objDNSServer.StopService if Err Then WScript.Echo "StopService failed: " & Err.Description Wscript.Quit end if objDNSServer.StartService if Err Then WScript.Echo "StartService failed: " & Err.Description Wscript.Quit end if WScript.Echo "Restart successful" DiscussionDNS Server runs as a service, which means you can also use the Services snap-in (services.msc) to start and stop it. When you stop DNS Server, it will no longer respond to DNS queries. You will also not be able to configure DNS Server while it is in a stopped state. This is because the DNS management tools, such as the DNS snap-in and dnscmd, communicate with DNS Server using RPC calls directly to that service. If the service is stopped, those tools won't work. If you do not want DNS Server to respond to queries, but you still want to be able to configure it, there is another option; DNS Server can be paused. For clients, this is effectively the same as stopping the service because it will not respond to DNS queries, but because the service remains up, you can use the management tools to configure it. To pause the DNS Server, follow the same steps outlined in the graphical user interface section, but select Pause from the list of All Tasks. To unpause (or resume) the server, select Resume. From a command line, use these commands to pause and resume the server, respectively: > sc \\<ServerName> pause dns > sc \\<ServerName> continue dns
If you want to take only a single zone offline, you can pause just that zone. dnscmd supports pausing and resuming zones, as shown here: > dnscmd <ServerName> /zonepause <ZoneName> > dnscmd <ServerName> /zoneresume <ZoneName> This works as you might expect. When a zone is in the paused state, DNS Server will not respond to client queries for records in that zone, but you can still make configuration changes to it. See AlsoRecipe 7.1, MSDN: MicrosoftDNS_Server, and MSDN: MicrosoftDNS_Zone |