Recipe13.2.Starting and Stopping the DNS Server


Recipe 13.2. Starting and Stopping the DNS Server

Problem

You want to start or stop the DNS Server.

Solution

Using a graphical user interface

  1. From the Administrative Tools, open the DNS snap-in (dnsmgmt.msc).

  2. In the left pane, right-click on the server and select All Tasks. From here you can select either Stop to stop the DNS Server or Start to start it.

Using a command-line interface

You 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"

Discussion

DNS 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

From VBScript, the MicrosoftDNS_Server class doesn't support pausing and resuming the DNS Server, but the Win32_Service class does.


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 Also

Recipe 7.1, MSDN: MicrosoftDNS_Server, and MSDN: MicrosoftDNS_Zone



Windows Server Cookbook
Windows Server Cookbook for Windows Server 2003 and Windows 2000
ISBN: 0596006330
EAN: 2147483647
Year: 2006
Pages: 380
Authors: Robbie Allen

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net