Search This Blog

Monday 19 March 2012

How to Add a DHCP Server from Command line in Windows Server 2008

 Windows Server 2008, we can setup the DHCP Server role and configure DHCP paramters including Scope, IP Range etc and the startup type all from command line. This is especially useful, if you are using Windows Server Core installation.
The following step by step procedure should help you just do that:
Install DHCP Server role
The following command from thecommand prompt should add the DHCP Server Role.
C:\Users\Administrator>start /w ocsetup DHCPServer
In Windows Server 2008 Core, the Role name is “DHCPServerCore”. So, in Windows Server 2008 Core installation, it is
C:\Users\Administrator>start /w ocsetup DHCPServerCore
Set DHCP Service to be Automatic
By default, after the role is enabled, the Service is still disabled. Hence Set the type to Auto as follows
C:\Users\Administrator> sc config dhcpserver start= auto
Start the DHCP Server
C:\Users\Administrator>net start dhcpserver
Add DHCP Server and Authroize in AD
If the DHCP server is installed in an Active Directory domain, you must authorize it in ActiveDirectory. Now, let’s use the netsh commands to setup the server and configure the relevant parameters.
C:\Users\Administrator>netsh dhcp add server dc1 192.168.0.5
Adding server dc1, 192.168.0.5
Command completed successfully.
Where DC1, is the DHCP Server and the IP Address follows it
Add DHCP Scope
C:\Users\Administrator>netsh dhcp server 192.168.0.5 add scope 192.168.10.0 255.255.255.0 Scope1 Scopevlan10
Command completed successfully.
In the above the
DHCP scope – 192.168.10.0 255.255.255.0
Scope1 – Scope Name
ScopeVlan10 – Comment for the scope
Syntax is
netsh dhcp server 192.168.0.5 add scope <Subnet> <Subnet mask> <ScopeName> <Scope comment>
Set Scope IP Range
C:\Users\Administrator>netsh dhcp server 192.168.0.5 scope 192.168.10.0 add ipra nge 192.168.10.1 192.168.10.254
Changed the current scope context to 192.168.10.0 scope.
Command completed successfully.
Here the IP range is 192.68.10.1-192.168.10.254 for the scope 192.168.10.0
Syntax is
netsh dhcp server <Server> scope 192.168.10.0 add iprange <StartIP> <EndIP>
Add Exclusion Range
Add any IP Exclusion ranges if any.
C:\Users\Administrator>netsh dhcp server 192.168.0.5 scope 192.168.10.0 add excluderange 192.168.10.1 192.168.10.25
Changed the current scope context to 192.168.10.0 scope.
Command completed successfully.
Here the exclusion list has the range between 192.168.10.1 to 192.168.10.25
Syntax is
netsh dhcp server <Server> scope <Scope> add excluderange <StartExclusion> <End-Exclusion>
Set Option Code 003 for Default Routers
Set the option Code 003 and specify the Gateways
C:\Users\Administrator>netsh dhcp server 192.168.0.5 scope 192.168.10.0 set optionvalue 003 IPADDRESS 10.1.1.1 10.1.1.2
Changed the current scope context to 192.168.10.0 scope.
Command completed successfully.
Here the gateways are 10.1.1.1 & 10.1.1.2
Syntax is
netsh dhcp server <Server> scope 192.168.10.0 set optionvalue 003 IPADDRESS <Gateway1> <Gateway2>
Set Option Code 006 for Default DNS Servers
C:\Users\Administrator>netsh dhcp server 192.168.0.5 scope 192.168.10.0 set optionvalue 006 IPADDRESS 192.168.0.5 192.168.10.1
Changed the current scope context to 192.168.10.0 scope.
Command completed successfully.
Here the DNS Servers are 192.168.0.5 & 192.168.10.1
Syntax is
netsh dhcp server <Server> scope 192.168.10.0 set optionvalue 006 IPADDRESS <Primary DNS> <Secondary DNS>
Activate DHCP Server Scope
Now, the relevant DHCP settings are complete. Lets activate the Scope
C:\Users\Administrator>netsh dhcp server 192.168.0.5 scope 192.168.10.0 set state 1
Changed the current scope context to 192.168.10.0 scope.
Command completed successfully.
This should help you up and running with DHCP in less than 5 minutes. You can always modify from command line or by using DHCP MMC later on!!!

How to change the DHCP server default database path in Win server 2003


We have already discussed about how to setup DHCP server in win server 2003.In this tutorial we will see how to change the DHCP server default database path this is very useful if your c: drive is running out of space you can move this database in to other drives.
Procedure to follow
  • Click Start, click Settings, click Control Panel, double-click Administrative Tools, and then double-click DHCP.
  • From DHCP/applicable DHCP server – click the applicable DHCP server
  • On the Action menu, click Properties.
  • In Server Properties, click the Advanced tab, select Database path, and then delete the default database path (default DHCP server database path located at C:\WINDOWS\System32\Dhcp).

How to create DNS Reverse Lookup Zone in Windows Server 2003

We have already discussed about how to install windows server 2003 domain controller with DNS server setup and DHCP server setup.Now we are going to discuss one more important topic how to createreverse lookup zone.
DNS allows two main types of queries: forward lookups and reverse lookups. A forward lookup searches for an IP address based on a provided host name.
A reverse lookup performs the opposite. It queries DNS for a host name based on an IP address. For example, some e-mail servers perform a reverse DNSlookup on a sending mail server to determine that the host name offered by the remote mail server actually matches the IP address of the SMTP connection attempting to deliver the message.
Follow the steps below to create a Windows server 2003 DNS Reverse lookup zone
Note: This procedure assumes that you have the appropriate permission to perform this task and that you already have a DNS Forward Lookup Zone created.
Creating A Reverse Lookup Zone
Click Start—>Administrative Tools—>DNS MMC.
This will open DNS MMC right mouse click on “Reverse Lookup Zones” and from the context menu select “New Zone”.
Now this will begin the New Zone Wizard and click “Next” to continue.
Select “Primary Zone” to create a copy of your zone and click “Next” to continue.
Tip: You can select the check box at the bottom of the New Zone Wizard on a Domain Controller (DC) to store the zone information in Active Directory (AD).
From the “Active Directory Zone Replication Scope” dialog box select one of the radial button options or accept the default of “To all domain controllers in the Active Directory domainName.Com and click “Next”.
At the “Reverse Lookup Zone Name” dialog box for the “Network ID:” enter the first three octets of the IP address for the IP addresses for the zone and click next to continue. For example if your IP Addresses are 10.10.10.xxx then enter 10.10.10.
From the “Dynamic Update” dialog box select one of the radial button options or accept the default of “Allow only secure dynamic updates (recommended for Active Directory)” and click next to compete the task.
Review the “Completing the New Zone Wizard” dialog box for any errors by reviewing the following for the example above and click “Finish” to create the reverse lookup zone:
Name: 10.10.10.in-addr.arpa
Type: Active Directory – Integrated Primary
Lookup type: Reverse
Finally review the new zone by expanding the “10.10.10.x Subnet” where you should see the newly created records including an A Record for the DNS server.
Tip: If you do not see any records right mouse click on the newly created zone and from the context menu select “Reload”.
Creating PTR Records
You can do this in two ways
1) Manually Create PTR Record
2) Automatically creating A and PTR records
1) Manually Create PTR Record
Now you need to create a Pointer (PTR) record for your reverse lookup for the DNS server by following the steps below
Right click on “10.10.10.x Subnet” and from the context menu select “New Pointer (PTR)…” to bring up the New Resource Record dialog box.
For the “Host IP Number:” enter the last octet of the DNS server’s IP address. For example if the IP Address is 10.10.10.2 then enter: 2. For the “Host name:” browse for the DNS server or enter the DNS servers Fully Qualified Domain Name (FQDN) such as MyAdDomain.Com and when you are finished click “OK”.
Finally right mouse click on “10.10.10.x Subnet” and from the context menu refresh the new information by selecting “Reload”.
2) Automatically creating A and PTR records
If you are using DHCP with DNS server you can use this with the following procedure
Go to Start–>Administrative tools—>DHCP
This will open DHCP MMC snapin now you need to right click on your DHCP select properties this will bring properties windows now click on DNS tab under this select “Always dynamically Update DNS A and PTR Records.

Enabling DHCP Support for Multiple Subnets Using DHCP Relay Agent in Win Server 2003

If you have multiple subnets in your network, and do not have a DHCP server on every subnet, determine whether your current routers relay DHCP/BOOTP messages.
If your routers cannot be used for DHCP/BOOTP relay, set up a DHCP/BOOTP relay agent on at least one computer running Windows Server 2003 on each subnet. The DHCP/BOOTP relay agent relays DHCP and BOOTP message trafficbetween the DHCP-enabled clients on the local network and a remote DHCP server located on another physical network by using the IP address of the remote DHCP server.
If your routers cannot be used for DHCP/BOOTP relay and you choose not to configure DHCP/BOOTP relay agents, you must configure your network so that a DHCP server has a network adapter on each subnet it serves. You can accomplish this by either placing a DHCP server on each subnet, or by multihoming DHCP servers. This distributed configuration does not provide fault tolerance. If a DHCP server becomes unavailable, DHCP clients on the subnet cannot receive IP addresses and options.
Add the DHCP Relay Agent
To add the DHCP Relay Agent follow this procedure
Go to Start—>Administrative Tools—> Open Routing and Remote Access.
From Routing and Remote Access/server name/IP Routing/General – click general
Right-click General, and then click New Routing Protocol.
In the Select Routing Protocol dialog box, click DHCP Relay Agent, and then click OK.
Configure global DHCP Relay Agent properties
To configure global DHCP Relay Agent properties
Go to Start—>Administrative Tools—> Open Routing and Remote Access.
From Routing and Remote Access/server name/IP Routing/DHCP Relay Agent click DHCP Relay Agent.
Right-click DHCP Relay Agent, and then click Properties.
On the General tab, in Server address, type the IP address of your DHCP server, and then click Add.
Repeat the above step for each DHCP server you need to add, and then click OK.
Enable the DHCP Relay Agent on a router interface
To enable the DHCP Relay Agent on a router interface
Go to Start—>Administrative Tools—> Open Routing and Remote Access.
From Routing and Remote Access/server name/IP Routing/DHCP Relay Agent, click DHCP Relay Agent.
Right-click DHCP Relay Agent, and then click New Interface.
Click the interface you want to add, and then click OK.
In the DHCP Relay Properties dialog box, on the General tab, verify that the Relay DHCP packets check box is selected.
If needed, in Hop-count threshold and Boot threshold (seconds), click the arrows to modify the thresholds.

How to Setup DHCP Server in windows server 2008

We have already discussed how toinstall windows server 2008 and configuring domain controller with DNS server in windows server2008.Now we will see how to install and configure DHCP server.
A DHCP Server assigns IP addresses to client computers. This is very often used in enterprise networks to reduce configuration efforts. All IP addresses of all computers are stored in a database that resides on a server machine.
You need to open server manager from Start—>Administrative tools—>Server Manager
Once server manager opens click on Roles from left pane now you need to click on Add Roles from right pane
Now you can see introduction screen click next
Here you need to select the DHCP Server and click next
DHCP Server introduction details click next
First it will try to check your server is having static ip address or not if it detects it will display here and click next