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 ...

Get Windows Server Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.