Showing posts with label Manage DHCP Server. Show all posts
Showing posts with label Manage DHCP Server. Show all posts

Monday, January 20, 2014

Part–3 : PowerShell and DHCP : Configuring the DHCP Scope DHCP Server

 

 

Part – 1 : PowerShell and DHCP : Installing DHCP Server Role on Server 2012

Part – 2 :PowerShell and DHCP : DHCP Post-Install Configuration

 

 

In my previous post, we do the Post-Install configuration task for the DHCP Server.  Now it’s time to configure the DHCP Sever Scope. We can going to do the below configuration.

Configuration.

 

DHCP Configuration

Name

ID

 

 

IP Address Scope

 

192.168.1.100

192.168.1.200

DNS Server

6

 

 

Gateway

3

192.168.1.99

 

Domain Name

15

Amandhally.net

 

Subnet Mask

 

255.255.255.0

 

 

We configure our DHCP server to give us the automatic IP Address from Range 192.168.1.100 to 192.168.1.200.  Subnet mask  is “255.255.255.0” our Gateway’s IP Address is 192.168.1.99 and the IP Address of our DNS Server is “192.168.1.99”, and as a domain name for DHCP IP, I am using amandhally.net.

Scope

 

Before setting scopes, I want to bind the specific LAN card for DHCP Server ( as I have 2 LAN cards on my server), I don’t want to run DHCP server service on all of My LAN Cards,  to do that, I can use “Set-DhcpServerv4Binding” cmdlet.

You can see I have 2 Ethernet cards on my machine, and I want to run the DHCP server on the LAN card named as “for_dhcp”.  

Note: I renamed this LAN card manually, from “Local Area Network” to “for_dhcp”.

Now run the below command.

Set-DhcpServerv4Binding -InterfaceAlias "for_dhcp" -BindingState $true

clip_image002

 

Once it done, let cross check it by running the Get-DhcpServerv4Binding cmdlet.

 

clip_image004

Perfect, the Ethernet is bind.

 

Setting Scope.

 

Now, we have to set a scope for the DHCP Server, so that he can start giving us the IP addresses.

$nameScope = 'DHCP Delhi'

$startIP = '192.168.1.100'

$endIP = '192.168.1.200'

$subnetMask = '255.255.255.0'

For my ease, I set my settings is variable, so that is easy to change later on {idea for scripting } , and save them as a script file for later use.

Above, I am setting the name of the scope to “DHCP Delhi” and the DHCP server start leasing the IP Address from “192.168.1.100” to end IP address of “192.168.1.200”. and my subnet mask will be “255.255.255.0”.

We have to set all of above using the “Add-DhcpServerv4Scope” cmdlet.

Now, Once you set the variable, run the below command. By using –State parameter to True, we are making this scope active.

Add-DhcpServerv4Scope -Name $nameScope -StartRange $startIP -EndRange $endIP -SubnetMask $subnetMask -State Active

Or

Add-DhcpServerv4Scope -Name 'DHCP Delhi'-StartRange '192.168.1.100' -EndRange $'192.168.1.200' -SubnetMask '255.255.255.0'-State Active

 

clip_image006

Once the above command run successfully, open your DHCP Server Manager and you can see that we have a new scope and that scope it Active.

clip_image008

 

Even our DHCP Sever is started giving the address to other laptop on the network too.

clip_image010

 

And I run Ipconfig /release and then Ipconfig /renew on another laptop and he gets the IP address from our server too.

clip_image012

 

Now, when you open the console, you can see our DHCP Server has given 2 ips to the computers.

Great J Isnt’

clip_image014

 

Till, now , we are successfully able to get the IP address on client system from our DHCP Server, But we won’t able to connect to Internet or other services, until we configure the Router and DNS options in the DHCP Server,

In our next blog post we are going to do that.

See you in my next blog post.

 

 

Regards
Aman Dhally
 
clip_image017 clip_image018 clip_image019 clip_image020  clip_image021

Thursday, January 16, 2014

Part 2–: PowerShell and DHCP : DHCP Post-Install Configuration


Part – 1 : PowerShell and DHCP : Installing DHCP Server Role on Server 2012

Doing Post-Install Configuration tasks


In my previous post, we go through the steps for installing the DHCP Server role on our windows server 2012. In this post we are going to do the DHCP Post Configuration tasks, which contains two steps for a standalone (Workgroup) server.
1.       Creating Security Groups
a.       DHCP Administrators
b.      DHCP Users
2.       Supressing the post-install configuration alert.

Note: I am running a non-domain server, which is just a standalone workgroup computer, if you want to do post-installation configuration on domain joined server, than the few steps are different as per compared to the workgroup server.

After installing the DHCP server roles, we have to complete the DHCP Server Post installation tasks. 

So, when you open the server manager console, you will see the below warning error, “Configuration required for DHCP Server at DHCP-Server1.

1

When you click on it, it will ask you to complete an action to Complete DHCP Configuration.

2
When you click on “Complete DHCP configuring”, you will see that it will ask to create 2 Security groups, one is “DHCP Administrators” and another one is “DHCP Users”.
Now Click on Cancel, yes on Cancel and go back to our PowerShell Console.

3

As, I told you before, that we will try to configure DHCP Server using PowerShell as much as we can.

Note : With Server 2012 R2, you can use the Add-DHCPServerSecurityGroup to add the two groups.No need to manually add them using ADSI! (Thanks to Sir Thomas Lee for suggestions.

Now, run the below script and then open Local users and Groups.

# Creating a group for DHCP Server
   # This Step is required for WorkGroup only server,
   # If your server is joined to the Domain, this steps are not valid.

$objectOU = [ADSI]"WinNT://$env:COMPUTERNAME"
$group = $objectOU.Create("Group","DHCP Users")
$group.CommitChanges()

$groupAdmin = $objectOU.Create("Group","DHCP Administrators")
$groupAdmin.CommitChanges()


4

Once you run the above script, you, can see that desired groups are created.

5

But, when you open Server Manager Console again you will see the same error again.

6

To supress this error, we need to change a registry settings, and then we need to restart the DHCP Server Service.
Run the below command to change the Registry value, to change the registry value, run the below command.

Set-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\ServerManager\Roles\12 -Name ConfigurationState -Value 2

7

Now, restart the DHCP Server Service.
Restart-Service -Name DHCPServer –Force

8

Now, open Server Manager again, and you can see there are not errors related to “DHCP Server Post Configuration”.
9

That’s all.
Now our POST configuration task is done, now next we have to start configuring the server…


Regards
Aman Dhally
clip_image017 clip_image018 clip_image019 clip_image020  clip_image021


Thursday, January 9, 2014

Part – 1 : PowerShell and DHCP : Installing DHCP Server Role on Server 2012

New PowerShell Series

After publishing my “Event Logs and PowerShell” series, I am posting another PowerShell article series, this article series is on installing, configuring, maintain DHCP Server using PowerShell.

In this series, we will configure a DHCP Server from scratch and we configure it using PowerShell. We will try to use as much as PowerShell as we can.

Side by side, we also try to generate a small simple script, those are help us to automate the whole deployment.

Background

If you are a system administrator like me, our main job is to configuring and deploying servers with different or same server roles.

Sometime with a different configurations and sometime with exactly the same configuration of another servers.

 For example if you are about to deploy a DHCP Server in any of your regional office or local office, I am sure that most of the settings will remain same like other DHCP servers.

Rather than doing the same thing manually again and again, we will use PowerShell to automate it, in this series, I will start configuring DHCP sever from the PowerShell console, but in the end we will try to write a small script to automate the whole manual task.

Specification

I am going to use Windows Server 2012 as a DHCP Server, and a windows 7 as client system, both are the virtual machine those are running on windows Hyper-V.

Configuration

Our DHCP Server configuration should be simple. The below is the list of task which we are going to do.

1.       Install the DHCP role on Server 2012

2.       Configure

a.       DHCP Scope

b.      Authorise Server

c.       Configure DNS Option

d.      Configure Router Option

e.      Configure DNS Domain Name option

f.        See if we manage to set Reservation

3.       Start DHCP Server

4.       Test it

May be we added more task, if needed arise.

Note

Before installing the DHCP serve role, make sure your would be DHCP server has STATIC IP Address, otherwise you will get the below warning error while installing the DHCP server role.

clip_image002[5]

Installing DHCP Role

 

Our first step is to install the DHCP role, but before installing the serve role, we have to check  if the role is already installed or not.

We can use Get-WindowsFeature cmdlet to check which role are currently Installed, or Available to install or Removed.

clip_image003

 

We are interested in installing, the DHCP server role.  You can see that DHCP Role is available but not installed.

clip_image005

 

Now using let’s check for DHCP Server Role Only, you can see in the below output that the DHCP role is available but it is  not installed.

Get-WindowsFeature -Name 'DHCP'

clip_image007

 

Now, let’s install DHCP Server Role, by using the cmdlet “Install-WindowsFeature”.  And in             –Name  parameter, we have to provide the Name of server role as argument , which role we want to install, in our case it is “DHCP”.

Install-WindowsFeature -Name 'DHCP' –IncludeManagementTools

 

clip_image009

 

clip_image010[5]

 

Once the command run successfully. You can see that the EXIT code is showing Success and value of success is True. That means DHCP Server role in installed successfully.

clip_image012[5]

Let’s run Get-WindowsFeature -Name 'DHCP'again to verify if role is installed or not.

Now you can check that install State of server role in installed now.

clip_image014[5]

 

Now, when you open server manager, and in Roles and features you can see a DHCP Server role is there, and you can see in that You have a new DHCP option available underneath all Servers option.

 

clip_image016[5]

 

And when you click on them, you can see all things related to DHCP.

 

clip_image018[5]

 

When you click on Tools, you can see the DHCP , option there.

clip_image020[4]

 

And when you click on it DHCP manager will open.

clip_image022[4]

 

 

That’s all for today, see you in the next post.

 

 

Regards
Aman Dhally
clip_image017 clip_image018 clip_image019 clip_image020  clip_image021