Skip to content

Commit

Permalink
multi-subnet fix (for stretch clusters)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaromirk committed Jun 7, 2022
1 parent 18b5022 commit 79d6928
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions Scripts/3_Deploy.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,14 @@ If (-not $isAdmin) {
#configure native VLAN and AllowedVLANs
WriteInfo "`t Configuring NativeVLAN and AllowedVLANs"
if ($ManagementSubnetIDs){
$AllowedVLANs="$($LabConfig.AllowedVLANs),$(($HighestVLAN+1))-$($HighestVLAN+$($ManagementSubnetIDs.Count))"
$number1=$(($HighestVLAN+1))
$number2=$($HighestVLAN+$($ManagementSubnetIDs.Count))
if ($number1 -eq $number2){
$number=$number1
}else{
$number="$number1-$number2"
}
$AllowedVLANs="$($LabConfig.AllowedVLANs),$number"
}else{
$AllowedVLANs=$($LabConfig.AllowedVLANs)
}
Expand Down Expand Up @@ -1458,7 +1465,7 @@ If (-not $isAdmin) {
Foreach ($number in $using:ManagementSubnetIDs){
$IP="10.0.$number.1"
$AdapterName="Subnet$Number"
$NetAdapterName=(Get-NetAdapterAdvancedProperty | where displayvalue -eq $AdapterName).Name
$NetAdapterName=(Get-NetAdapterAdvancedProperty | Where-Object displayvalue -eq $AdapterName).Name
if (Get-NetIPAddress -InterfaceAlias $NetAdapterName -IPAddress $IP -ErrorAction Ignore){
Write-Output "`t`t Subnet $AdapterName already configured"
}else{
Expand All @@ -1467,9 +1474,6 @@ If (-not $isAdmin) {
#add dhcp scope
Write-Output "`t`t Adding DHCP Scope ID 10.0.$number.0 and it's DHCP options"
Add-DhcpServerv4Scope -StartRange "10.0.$number.10" -EndRange "10.0.$number.254" -Name "Scope$number" -State Active -SubnetMask 255.255.255.0
Set-DhcpServerv4OptionValue -OptionId 6 -Value "10.0.$number.1" -ScopeId "10.0.$number.0"
Set-DhcpServerv4OptionValue -OptionId 3 -Value "10.0.$number.1" -ScopeId "10.0.$number.0"
Set-DhcpServerv4OptionValue -OptionId 15 -Value "$($using:Labconfig.DomainName)" -ScopeId "10.0.$number.0"
}
}
#make sure RRAS features are installed
Expand All @@ -1484,6 +1488,13 @@ If (-not $isAdmin) {
#restart routing... just to make sure
Write-Output "`t`t Restarting service RemoteAccess"
Restart-Service RemoteAccess

#configure DHCP Options
Foreach ($number in $using:ManagementSubnetIDs){
Set-DhcpServerv4OptionValue -OptionId 6 -Value "10.0.$number.1" -ScopeId "10.0.$number.0"
Set-DhcpServerv4OptionValue -OptionId 3 -Value "10.0.$number.1" -ScopeId "10.0.$number.0"
Set-DhcpServerv4OptionValue -OptionId 15 -Value "$($using:Labconfig.DomainName)" -ScopeId "10.0.$number.0"
}
}
}

Expand Down

0 comments on commit 79d6928

Please sign in to comment.