Category: DHCP


commands to manage DHCP

Use Netsh to find authorised DHCP Servers

 

netsh dhcp show server

Use DSQuery to find authorised DHCP Servers

 

Dsquery * “cn=NetServices,cn=Services,cn=Configuration, DC=forestRootDomain” -attr dhcpServers

 DHCP server information

 

netsh dhcp server \\DHCP_SERVER show all

 DHCP server dump

 netsh dhcp server \\DHCP_SERVER dump >>FilePath

Adding Single scope through command prompt

 Syntax: 

netsh dhcp server \\servername add scope subnetID subnetmask “ScopeName”

 netsh dhcp Server \\servername Scope subnetID Add iprange IPRangevalue

 netsh dhcp Server \\servername Scope subnetID set optionvalue Optionnumber Datatype “Value”

 Example:

 netsh dhcp server \\indiaw1234 add scope 10.15.254.0 255.255.254.0 “INDIA” “INDIA Site”

 netsh dhcp Server \\indiaw1234 Scope 10.15.254.0 Add iprange 10.200.3.1 10.200.3.99

 netsh dhcp Server \\indiaw1234 Scope 10.15.254.0 set optionvalue 3 IPADDRESS “10.200.3.154”

 netsh dhcp Server \\indiaw1234 Scope 10.15.254.0 set optionvalue 6 IPADDRESS “159.12.83.60”

 netsh dhcp Server \\indiaw1234 Scope 10.15.254.0 set optionvalue 15 STRING “contoso.com”

 DHCP Reservation through Command

 Syntax:

 netsh dhcp Server \\servername Scope subnetID add reservedip <ipaddress> <MAC> <hostname> <description>

 Example:

 Dhcp Server \\indiaw1234 Scope 10.15.254.0 Add reservedip 10.15.254.120 0001e6ac351e “printer1.contoso.com” “printer1”

 Command to delete a Scope:

 Syntax:

 netsh dhcp server \\servername delete scope subnetID DHCPFULLFORCE

 netsh dhcp server \\indiaw1234 delete scope 10.15.254.0 DHCPFULLFORCE

 Command to Set server Option:

 Syntax:

 Netsh dhcp server \\servername set optionvalue optionnumber datatype value

 Example:

 Netsh dhcp server \\indiaw1234 set optionvalue 066 STRING 10.156.100.250

 Netsh dhcp server \\indiaw1235 set optionvalue 067 STRING \boot\x86

 Bulk Scope Creation:

 Syntax:

 For /f “token=number of input attributes delims=,” %%a in (file path) do netsh dhcp server DHCP SERVERNAME addscope Attributes.

 Example:

 for /f “tokens=1,2,3,4,5 delims=,” %%a in (C:\temp\dhcpscope.txt) do netsh dhcp server \\INDIA123 add Scope %%a %%b %%c

 for /f “tokens=1,2,3,4,5 delims=,” %%a in (C:\temp\dhcpscope.txt) do netsh dhcp Server \\INDIA123 Scope %%a Add iprange %%d

 for /f “tokens=1,2,3,4,5 delims=,” %%a in (C:\temp\dhcpscope.txt) do netsh dhcp Server \\INDIA123 Scope %%a set optionvalue 3 IPADDRESS %%e

 for /f “tokens=1,2,3,4,5 delims=,” %%a in (C:\temp\dhcpscope.txt) do netsh dhcp Server \\INDIA123 Scope %%a set optionvalue 6 IPADDRESS “160.200.134.150” “160.200.134.252”

 for /f “tokens=1,2,3,4,5 delims=,” %%a in (C:\temp\dhcpscope.txt) do netsh dhcp Server \\INDIA123 Scope %%a set optionvalue 15 STRING “contoso.com”

 for /f “tokens=1,2,3,4,5 delims=,” %%a in (C:\temp\dhcpscope.txt) do netsh dhcp Server \\INDIA123 Scope %%a set optionvalue 43 BINARY “616C636174656C2E61343430302E30”

 for /f “tokens=1,2,3,4,5 delims=,” %%a in (C:\temp\dhcpscope.txt) do netsh dhcp Server \\INDIA123 Scope %%a set optionvalue 66 STRING “105.41.11.225”

 for /f “tokens=1,2,3,4,5 delims=,” %%a in (C:\temp\dhcpscope.txt) do netsh dhcp Server \\INDIA123 Scope %%a set optionvalue 67 STRING “a44N6”

 for /f “tokens=1,2,3,4,5 delims=,” %%a in (C:\temp\dhcpscope.txt) do netsh dhcp Server \\INDIA123 Scope %%a set optionvalue 46 Byte “2”

 Sample Input:

 103.142.32.0,255.255.255.0,”Scope 1″,103.142.32.1 103.142.32.254,103.142.32.254

103.142.33.0,255.255.255.0,”Scope 2 “,103.142.33.1 103.142.33.254,103.142.33.254

103.142.34.0,255.255.255.0,”Scope 3″,103.142.34.1 103.142.34.254,103.142.34.254

103.142.35.0,255.255.255.0,”Scope 4”,103.142.35.1 103.142.35.254,103.142.35.254

Advertisements

Message -:A DHCP Server Error has occurred. The first event logged is detailed below, however examine System Event Logs for more detail.Event Number of first event recorded: 1014 The following problem occurred with the Jet database -1032: Jet database read or write operations failed. If the computer or database has just been upgraded, then this message can be safely ignored. If this message appears frequently, either there is not enough disk space to complete the operation or the database or backup database may be corrupt. To correct this problem, either free additional space on your hard disk or restore the database. After you restore the database, ensure that conflict detection is enabled in DHCP server properties. For information about restoring the database, see Help and SupportCenter. Additional Debug Information: JetBackup. (EventID = 1014)          (IAM Ref=000-000-002-000-043-000-001)

 Cause: The following problem occurred with the Jet database %1: Jet database read or write operations failed. If the computer or database has just been upgraded, then this message can be safely ignored. If this message appears frequently, either there is not enough disk space to complete the operation, or the database or backup database may be corrupt. To correct this problem, either free additional space on your hard disk, or restore the database. After you restore the database, ensure that conflict detection is enabled in DHCP server properties. For information about restoring the database, see Help and SupportCenter. Additional Debug Information: %2.

 Event ID: Event ID 1014 — DHCP Database Integrity

Event ID 1016 

Explanation: The DHCP service could not access the database to perform the backup

Possible causes include:

  • Another program is accessing the database.
  • The database and its backup directories were moved from the default location

 Resolution:

User Action: To resolve this problem, do one of the of the following:

  • Verify that other programs, such as an antivirus program, are not accessing the database. If such a program is accessing the database, make sure that the program does not scan the directory where the database is stored.
  • Verify that the database and its backup directories are located in the default folder.

Repair database and restore from a known good backup

If the DHCP server database becomes corrupted or is lost, recovery is possible by replacing the server database file (Dhcp.mdb), located in the %SystemRoot%\System32\Dhcp folder, with a backup copy of the same file.

If DHCP Manager was used previously to perform a backup, you can obtain the backup copy of the server database file located in the %SystemRoot%\System32\Dhcp\Backup folder. You can also restore the Dhcp.mdb file from a tape backup or other backup media.

To perform these procedures, you must be a member of the Administrators group, or you must have been delegated the appropriate authority.

To restore a backup copy of the DHCP database:

  1. Click Start, click All Programs, click Accessories, right-click Command Prompt, and then click Run as Administrator.
  2. Type net stop dhcpserver, and then press ENTER.
  3. Type md c:\olddhcp, and then press ENTER.
  4. Type move %SystemRoot%\system32\DHCP\*.* c:\olddhcp, and then press ENTER.
  5. Type del %SystemRoot%\system32\DHCP\Dhcp.md, and then press ENTER.
  6. Type copy%SystemRoot%\system32\dhcp\backup\jet\new\dhcp.mdb%SystemRoot%\system32\dhcp\dhcp.mdb, and then press ENTER.
  7. Type net start dhcpserver, and then press ENTER.

Verify

Confirm that the server starts successfully and without errors.

Possible causes are listed here pls use any of the below as reference while handling the IM.

 1.Jet database read or write operations failed due to Another program(Symantec AntiVirus) is accessing the database.

 2.Jet database read or write operations failed due to tcpsvcs (4160) An attempt to move the file “C:\WINNT\System32\dhcp\backup\new” to “C:\WINNT\System32\dhcp\backup\old” failed with system error 5 (0x00000005): “Access is denied. “.  The move file operation will fail with error -1032 (0xfffffbf8).

 3.Jet database read or write operations failed due totcpsvcs (4160) The backup has been stopped because it was halted by the client or the connection with the client failed.

 4.Jet database read or write operations failed due to Another program(Backup Exec) is accessing the database.

 Website for reference:

 http://technet.microsoft.com/en-us/library/cc726907(WS.10).aspx

 http://www.microsoft.com/technet/support/ee/transform.aspx?ProdName=Windows%20Operating%20System&ProdVer=5.2&EvtID=1016&EvtSrc=DHCPServer&LCID=1033