Quick Create a Windows Server 2012 R2 Network Load Balancing (NLB) ,How To , Step by Step #winserv #NLB #ws2012

As there are still many questions on how to setup a Windows NLB. Or not getting a working situation with all kind of different errors.

I made already two Blog post about NLB. This blog post will be a bit off Both.

https://robertsmit.wordpress.com/2014/08/20/create-a-new-network-load-balancing-nlb-cluster-on-windows-server-2012-r2-winserv-nlb/

https://robertsmit.wordpress.com/2012/06/26/windows-2012-clustering-network-load-balancing-nlb-how-to-step-by-step/

So for starting I have 4 NLB nodes MVPSQL141 to MVPSQL 144

The NLB tools I installed with Powershell Run this on every NLB node!

Install-WindowsFeature nlb –IncludeManagementTools

 

image

Now that the tools are installed We can start with the Configuration of the NLB.

Starting the NLB manager to Create the NLB cluster and joining the Other Nodes.

image

All my nodes have multiple network cards and for the NLB I use always a dedicated NIC to avoid problems.

I select the create new cluster from the menu and add the First NLB node.

image

As you can see there are 3 nic’s in this case I use the Ethernet connection. The Public connection is connected to the Domain.

And All NIC’s have a fixed IP Addresses.

image

As you can see the nic has a dedicated IP if the nic has a DHCP Address you can give here a fixed IP by selecting ADD

image

This step is adding the Cluster IP by selecting ADD and then choose the right NLB Cluster IP!

image

Right Creating a DNS name for the NLB Cluster.

image

As I will only use Port 80 I changed the Rule and selected only port 80. I does not make sense to select all the ports when using only 80 and or 443.

image

Now that the Cluster is created We can join other Nodes with add host to the cluster I the menu. You can do only One Node at the time. the same screens as above are showing so no reason to capture this. However I have one node that has no fixed IP

image

When Adding this node there is a little warning.

image image

As you can see the IP is not there therefore I do ADD and create a FIX IP on the NIC when I select Next the port policy will appear and the node Will be joined to the Cluster.

image

If anything fails to join the NLB node to the Cluster you need to look on this node. Creating NLB is a simple Process. Basic rule all nics need to See and Ping on FQDN and IP incoming and outgoing ! and make sure the NLB DNS entry is there and make sure the reversed lookup is also there!

When joining the NLB IP to IIS make sure you use the Cluster NLB IP and remove all other IP bindings!!

image

 

Happy nlb clustering

Robert Smit

@clusterMVP

https://robertsmit.wordpress.com

Create a New Network Load Balancing NLB Cluster On Windows Server 2012 R2 #Winserv #nlb

Still I thought NLB is so common that there is no point here to create a blog. but recently I see a lot of misconfigurations of NLB or people trying to do the easy way and not listen to the guidelines. So this blog is all about NLB only in the private cloud you can’t extend this to Azure even if you have a S2S.

So I have two servers in my private cloud.  MVPNLB001 and MVPNLB002 Both Machines have two NIC’s one for LAN and the other is for the NLB actions.

and yes it can be with one but with two is it much easier and fault tolerant. Less errors and less administration.

Both domain joined and ready for Setup of my basic IIS.

First we setup IIS with the Management tools

image

Install-WindowsFeature -Name Web-Server Or Add-WindowsFeature Web-WebServer –IncludeAllSubFeature to get all the features

Install-WindowsFeature -Name Web-Mgmt-Tools
Add-WindowsFeature NET-Framework-45-ASPNET

Get-WindowsFeature nlb*

 

image

add-WindowsFeature –Name NLB

add-WindowsFeature RSAT-NLB

Now we are ready to configure the NLB. We can do this With powershell but the GUI also Works.  ( I show both )

image 

 

The First Step will be Create a New NLB Cluster. As I do like things clear and therefor I start with rename the NIC names

Rename-NetAdapter -Name "Ethernet 2" -NewName "NLB"

Rename-NetAdapter -Name "Ethernet" -NewName "LAN"

imageimage

Open the NLB Manager and select Cluster NEW

imageimageimageimageimage

Or use powershell

Rename-NetAdapter -Name "Ethernet 2" -NewName "NLB"

New-NetIPAddress -IPAddress 10.255.255.93 -InterfaceAlias "NLB" -AddressFamily IPv4 -PrefixLength 24

In this case we renamed the adapter and give the nic a static IP.

The next steps Will be creating the NLB with his own IP and Remove the default port rule and use only ports that I want say port 80

imageimageimage

Well that was easy Creating the NLB Next step will be delete the port rule and create a 80 port rule 

imageimage

We will remove the default line and just create a rule for one port that I need in this case port 80

Network Load Balancing parameters

http://technet.microsoft.com/en-us/library/cc778263(v=ws.10).aspx

 

 

These steps can be done in just a few more PowerShell lines ( I use variables see below the post for the complete script )

#Creating new cluster
Write-Host "Creating NLB Cluster…" -ForegroundColor yellow
New-NlbCluster -ClusterName $ClusterFqdn -InterfaceName $InterfaceName -ClusterPrimaryIP $ClusterPrimaryIP -SubnetMask $ClusterPrimaryIPSubnetMask -OperationMode $OperationMode

#Removing default port rule for the new cluster
Write-Host "Removing default port rule…" -ForegroundColor yellow
Get-NlbClusterPortRule -HostName . | Remove-NlbClusterPortRule -Force

image

But now what we have only One Server and we need to add the other node or nodes.

imageimage

With two more confirmations screens you are done and have a Configured NLB on One 1 IP listening on port 80

Suppose you have multiple websites and all running on different IP or hostnames just add a cluster IP

imageimageimage

Now that the NLB is created We can do some testing

Now to get this to work with IIS

image

That is right page not found. Check the DNS see if the record is created. and make sure the website IIS is running on this IP

Go to the IIS manager and check the website bindings, default it is listening on all IP but this is not the behavior that I want I want a NLB. So we need to set the website on the NLB IP configured earlier.  When Having multiple IP on the NLB pick the right IP!

imageimageimageimage

Remember this you need to do this on all the Webservers!

image

 

A complete script to automate all these steps and add a second node. only the IP is fixed in the script and can be set as variable but this is up to you.

use this at free will. I created small steps so you can use also little steps if you need this or just give you an Idea.

<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

#Set IP for NLB
Write-Host "Set NLB IP and change Network adapter" -ForegroundColor yellow
Rename-NetAdapter -Name "Ethernet 2" -NewName "NLB"
New-NetIPAddress -IPAddress 10.255.255.93 -InterfaceAlias "NLB" -AddressFamily IPv4 -PrefixLength 24

#Set ExecutionPolicy
Write-Host "Set ExecutionPolicy" -ForegroundColor yellow
Set-ExecutionPolicy -scope LocalMachine RemoteSigned –force

#Add-WindowsFeature
Write-Host "Add-WindowsFeature NLB" -ForegroundColor yellow
add-WindowsFeature NLB
add-WindowsFeature RSAT-NLB

#Variables for creating the new cluster
Write-Host "Variables for creating the new cluster" -ForegroundColor yellow
$ClusterFqdn = Read-Host "Enter NLB cluster Name FQDN"
$InterfaceName = Read-Host "Enter interface name for NLB-adapter"
$ClusterPrimaryIP = Read-Host "Enter cluster primary IP"
$ClusterPrimaryIPSubnetMask = Read-Host "Enter subnetmask for cluster primary IP"

Write-Host "Choose cluster operation mode"
Write-Host "1 – Unicast"
Write-Host "2 – Multicast"
Write-Host "3 – IGMP Multicast"
switch (Read-Host "Enter the number for your chosen operation mode")
{
1 {$OperationMode = "unicast"}
2 {$OperationMode = "multicastcast"}
3 {$OperationMode = "igmpmulticast"}
default {Write-Warning "Invalid option, choose ‘1’, ‘2’ or ‘3’";return}
}

#Creating new cluster
Write-Host "Creating NLB Cluster…" -ForegroundColor yellow
New-NlbCluster -ClusterName $ClusterFqdn -InterfaceName $InterfaceName -ClusterPrimaryIP $ClusterPrimaryIP -SubnetMask $ClusterPrimaryIPSubnetMask -OperationMode $OperationMode

#Removing default port rule for the new cluster
Write-Host "Removing default port rule…" -ForegroundColor yellow
Get-NlbClusterPortRule -HostName . | Remove-NlbClusterPortRule -Force

#Adding port rules

Add-NlbClusterPortRule -Protocol Tcp -Mode Multiple -Affinity Single -StartPort 80 -EndPort 80 -InterfaceName $InterfaceName | Out-Null
Write-Host "Added port rule for http (tcp 80)" -ForegroundColor yellow

Add-NlbClusterPortRule -Protocol Tcp -Mode Multiple -Affinity Single -StartPort 443 -EndPort 443 -InterfaceName $InterfaceName | Out-Null
Write-Host "Added port rule for https (tcp 443)" -ForegroundColor yellow

#Adding additional cluster nodes based on user input
Write-Host "Give Second NLB host" -ForegroundColor yellow
$Node2Fqdn = Read-Host "Enter 2e NLB node"

#Set Network Adapter
Enter-PSSession -ComputerName $Node2Fqdn
invoke-command -computername $Node2Fqdn -scriptblock { Rename-NetAdapter -Name "Ethernet 2" -NewName "NLB"}
invoke-command -computername $Node2Fqdn -scriptblock { New-NetIPAddress -IPAddress 10.255.255.92 -InterfaceAlias "NLB" -AddressFamily IPv4 -PrefixLength 24}
Write-Host "Placed NLB IP and changed NIC to NLB" -ForegroundColor yellow
exit-PSSession

#Add-WindowsFeature
Write-Host "Add-WindowsFeature NLB" -ForegroundColor yellow
Enter-PSSession -ComputerName $Node2Fqdn
invoke-command -computername $Node2Fqdn { add-WindowsFeature NLB}
invoke-command -computername $Node2Fqdn { add-WindowsFeature RSAT-NLB}
exit-pssession

#Add Remote Node To NLB
Write-Host "Adding cluster node $Node2Fqdn" -ForegroundColor yellow
Get-NlbCluster | Add-NlbClusterNode -NewNodeName $Node2Fqdn -NewNodeInterface NLB

 

Have fun

Robert Smit

Twitter : @clustermvpTwitter : @clustermvp

https://robertsmit.wordpress.com/