Recipe 14.1. Installing DHCP ServerProblemYou want to install the DHCP Server service. SolutionUsing a graphical user interface
Using a command-line interfaceFirst, create a file using a text editor such as Notepad with the following contents: [netoptionalcomponents] dhcpserver=1 Next, use the sysocmgr.exe utility with the following parameters (assuming the file you just created is named c:\dhcp_install.txt ): > sysocmgr /i:%windir%\inf\sysoc.inf /u:c:\dhcp_install.txt Using VBScriptUnfortunately, there aren't any scripting APIs for installing the DHCP Server. One option would be to run the sysocmgr command from within a script. DiscussionThe DHCP Server service is an optional Windows Component, so you can install it using the Add or Remove Programs applet in the Control Panel. There are no configuration options when you install the DHCP Server, so installation is a breeze. After you've installed the service, you'll need to authorize the server, if you have an Active Directory environment, as described in Recipe 14.2. If the server you installed DHCP on is multihomed (i.e., has multiple active network adapters), you'll want to make sure the correct network adapters are enabled for use by the DHCP Server. You can enable or disable adapters for use by DHCP Server by doing the following:
See AlsoRecipe 2.4 and Recipe 14.2 |
Recipe 14.2. Authorizing a DHCP ServerProblem
You want to permit (i.e., authorize) a DHCP Server to process DHCP
Solution
Using a graphical
|
|
Open the DHCP snap-in.
In the left pane, right-click on DHCP and select Add Server .
Type in the
Click on the server entry in the left pane.
Right-click on the server and select Authorize .
|
The following command authorizes a DHCP Server in Active Directory:
> netsh dhcp add server <DHCPServerName> <DHCPServerIP>
This example shows how to authorize the DHCP Server named dhcp01.rallencorp.com with IP 192.168.191.15:
> netsh dhcp add server dhcp01.rallencorp.com 192.168.191.15
See the Introduction for more information on how to run the netsh command from within a script. The following script prints out the list of authorized DHCP Servers in Active Directory:
' ------ SCRIPT CONFIGURATION ------
strForestRootDN = "
<ForestRootDN>
" ' e.g., dc=rallencorp,dc=com
' ------ END CONFIGURATION ---------
set objCont = GetObject("LDAP://CN=DhcpRoot,CN=NetServices,CN=Services," & _
"CN=Configuration," & strForestRootDN)
colDHCPServers = objCont.GetEx("dhcpServers")
for each strDHCPServer in colDHCPServers
Wscript.Echo strDHCPServer
next
Windows 2000 and Windows Server 2003-based DHCP servers that belong to an Active Directory domain must be authorized before they can give out leases to clients. This feature helps reduce the danger of a rogue Windows 2000 or Windows Server 2003 DHCP Server that an end-user sets up, perhaps unintentionally. A rogue DHCP Server can provide incorrect lease information or deny lease requests altogether, ultimately
If the DHCP Server service is enabled on a domain controller, it is automatically authorized. A DHCP Server that is a member server of an Active Directory domain
A standalone DHCP server that is not a member of an Active Directory domain sends out a DHCPINFORM message when it first initializes. If an authorized DHCP Server responds to the message, the standalone server will not respond to any further DHCP requests. If it does not receive a response from a DHCP Server, it will respond to client requests and give out leases.
DHCP servers are represented in Active Directory as objects of the dhcpClass class, which can be found in the cn=NetServices,cn=Services,cn=Configuratation, <ForestRootDN> container. The relative distinguished name of these objects is the DHCP Server's IP address. There is also an object in the same container named cn=dhcpRoot , which is created after the first DHCP Server is authorized. It has an attribute named dhcpServers that contains all authorized servers. I enumerated this attribute in the VBScript solution to display all authorized servers.
By default, only
Open ADSI Edit from the Support Tools while logged on as a member of the Enterprise Admins group.
In the left pane, expand the
Configuration Container
CN=Configuration
CN=NetServices
.
Right-click on CN=NetServices and select Properties .
Select the Security tab.
Click the Advanced button.
Click the Add button.
Use the object picker to select the DHCP Admins group.
Check the boxes under Allow for Create dHCPClass objects and Delete dHCPClass objects .
Click OK until all dialog boxes are closed.
Back in the left pane of ADSI Edit, right-click on CN=dhcpRoot (if you've previously authorized DHCP Servers) and select Properties .
Select the Security tab.
Click the Advanced button.
Click the Add button.
Use the object picker to select the DHCP Admins group.
Check the boxes under Allow for Write .
Click OK until all dialog boxes are closed.
You can quickly determine whether a DHCP Server has been authorized by looking at its server node in the left pane of the DHCP snap-in. If the icon has a little red flag, that means it isn't authorized, if it is green, then it is authorized.
To see the list of authorized servers using the command line, run the following command:
> netsh dhcp show server
MS KB 279908 (Unexpected Results in the DHCP Service Snap-In After Using NETSH to Authorize DHCP), MS KB 300429 (HOW TO: Install and Configure a DHCP Server in an Active Directory Domain in Windows 2000), and MS KB 303351 (How to Use Netsh.exe to Authorize, Unauthorize, and List DHCP Servers in Active Directory), MS KB 306925 (Cannot Authorize New DHCP Server in Active Directory), and MS KB 323360 (HOW TO: Install and Configure a DHCP Server in an Active Directory Domain in Windows Server 2003)