Chore: DNS Server config wip

This commit is contained in:
Alexandre-Simao 2021-06-01 11:40:58 +02:00
parent 781e92ec5c
commit 6244d23cba
4 changed files with 63 additions and 84 deletions

View File

@ -2,7 +2,7 @@
# GPL v3 # GPL v3
# SRV-01 ONLY # SRV-01 ONLY
# bol.locks domain # asrbd.local domain
# TODO: Delegation # TODO: Delegation
@ -103,7 +103,7 @@ $Params = @{
Set-NetFirewallRule @Params Set-NetFirewallRule @Params
# END # END
### Add routes for RTR-01 ### Add routes for SRV-01
echo "Add routes for RTR-01" echo "Add routes for RTR-01"
route add -p 192.168.12.0/24 192.168.8.254 route add -p 192.168.12.0/24 192.168.8.254
@ -121,21 +121,28 @@ Get-DhcpServerv4Scope | Set-DhcpServerv4OptionValue -DnsServer 192.168.128.1,192
### Installing and configuring DNS role ### Installing and configuring DNS role
# Install and configure DNS server # Install and configure DNS server
Install-WindowsFeature -Name DNS -IncludeManagementTools -includeallsubfeature Install-WindowsFeature -Name DNS -IncludeManagementTools -includeallsubfeature
Add-DnsServerPrimaryZone -NetworkID 192.168.8.0/24 -ZoneFile 192.168.8.1.in-addr.arpa.dns # Zone secondaire #Add-DnsServerPrimaryZone -NetworkID 192.168.8.0/24 -ZoneFile “192.168.8.1.in-addr.arpa.dns” # Zone secondaire
Add-DnsServerPrimaryZone -Name "bol.locks" -ZoneFile "bol.locks.dns" Add-DnsServerPrimaryZone -Name "asrbd.local" -ZoneFile "asrbd.local.dns" -DynamicUpdate None
Set-DnsServerPrimaryZone -ComputerName SRV-01 -Name asrbd.local -SecureSecondaries "TransferToSecureServers" -SecondaryServers "192.168.128.1"
#Set-DnsServerResourceRecord -NewInputObject srv-01.asrbd.local -OldInputObject srv-01. -ZoneName "asrbd.local" -RRType SOA
$old= Get-DnsServerResourceRecord -ZoneName $allzone.ZoneName -Name @ -RRType Soa
$new = $old.Clone()
$new.RecordData.Name
Add-DnsServerForwarder -IPAddress 9.9.9.9 -PassThru # Forward Add-DnsServerForwarder -IPAddress 9.9.9.9 -PassThru # Forward
Add-DnsServerResourceRecordA -Name "SRV-01" -ZoneName "bol.locks" -IPv4Address "192.168.8.1" -TimeToLive 01:00:00 Add-DnsServerResourceRecordA -Name "SRV-01" -ZoneName "asrbd.local" -IPv4Address "192.168.8.1" -TimeToLive 01:00:00
Add-DnsServerResourceRecordA -Name "SRV-02" -ZoneName "bol.locks" -IPv4Address "192.168.8.2" -TimeToLive 01:00:00 Add-DnsServerResourceRecordA -Name "SRV-02" -ZoneName "asrbd.local" -IPv4Address "192.168.8.2" -TimeToLive 01:00:00
Add-DnsServerResourceRecordA -Name "NAT" -ZoneName "bol.locks" -IPv4Address "192.168.255.254" -TimeToLive 01:00:00
Test-DnsServer -IPAddress 192.168.8.1 -ZoneName "bol.locks" #Test Test-DnsServer -IPAddress 192.168.8.1 -ZoneName "asrbd.local"
Test-DnsServer -IPAddress 192.168.128.1 -ZoneName "micro.bou.local" Test-DnsServer -IPAddress 192.168.128.1 -ZoneName "asrbd.dev"
Test-DnsServer -IPAddress 192.168.8.1 -ZoneName "asrbd.dev"
Test-DnsServer -IPAddress 192.168.128.1 -ZoneName "asrbd.local"
Read-Host "DNS Tests" Read-Host "DNS Tests"
# Add local DNS for all Hosts # Add local DNS for all Hosts

View File

@ -90,7 +90,7 @@ Restart-Computer
# GPL v3 # GPL v3
# SRV-01 ONLY # SRV-01 ONLY
# bol.locks domain # asrbd.local domain
# TODO: # TODO:
@ -159,17 +159,19 @@ route add -p 0.0.0.0/0 192.168.128.254
# Install and configure DNS server # Install and configure DNS server
#Install-WindowsFeature -Name DNS -IncludeManagementTools -includeallsubfeature# Install-WindowsFeature -Name DNS -IncludeManagementTools -includeallsubfeature#
#Add-DnsServerPrimaryZone -NetworkID 192.168.8.0/24 -ZoneFile “192.168.8.1.in-addr.arpa.dns” # Zone secondaire #Add-DnsServerPrimaryZone -NetworkID 192.168.128.0/24 -ZoneFile “192.168.8.1.in-addr.arpa.dns” # Zone secondaire
#Add-DnsServerPrimaryZone -Name "bol.locks" -ZoneFile "bol.locks.dns" Add-DnsServerPrimaryZone -Name "asrbd.dev" -ZoneFile "asrbd.dev.dns" -DynamicUpdate None
#Add-DnsServerForwarder -IPAddress 9.9.9.9 -PassThru # Forward Add-DnsServerPrimaryZone -Name "dev.asrbd.local" -ZoneFile "dev.asrbd.local.dns"
Add-DnsServerForwarder -IPAddress 9.9.9.9 -PassThru # Forward
#Add-DnsServerResourceRecordA -Name "SRV-01" -ZoneName "bol.locks" -IPv4Address "192.168.8.1" -TimeToLive 01:00:00 Add-DnsServerResourceRecordA -Name "SRV-03" -ZoneName "asrbd.dev" -IPv4Address "192.168.128.1" -TimeToLive 01:00:00
#Add-DnsServerResourceRecordA -Name "SRV-02" -ZoneName "bol.locks" -IPv4Address "192.168.8.2" -TimeToLive 01:00:00
#Add-DnsServerResourceRecordA -Name "NAT" -ZoneName "bol.locks" -IPv4Address "192.168.255.254" -TimeToLive 01:00:00
#Test-DnsServer -IPAddress 192.168.8.1 -ZoneName "www.darty.fr" #Test Test-DnsServer -IPAddress 192.168.8.1 -ZoneName "asrbd.local"
Test-DnsServer -IPAddress 192.168.128.1 -ZoneName "asrbd.dev"
Test-DnsServer -IPAddress 192.168.8.1 -ZoneName "asrbd.dev"
Test-DnsServer -IPAddress 192.168.128.1 -ZoneName "asrbd.local"
# Add BGINFO autostart # Add BGINFO autostart

View File

@ -11,20 +11,11 @@ echo "Adding and configuring SRV-01"
cp D:\VHD\Base\Base_SRV_diff.vhdx D:\VHD\SRV-01.vhdx cp D:\VHD\Base\Base_SRV_diff.vhdx D:\VHD\SRV-01.vhdx
Mount-VHD d:\VHD\SRV-01.vhdx Mount-VHD d:\VHD\SRV-01.vhdx
<<<<<<< HEAD
Copy-Item D:\Scripts\Unattend\FullUnattend-srv.xml -Destination e:\Windows\Panther\Unattend.xml Copy-Item D:\Scripts\Unattend\FullUnattend-srv.xml -Destination e:\Windows\Panther\Unattend.xml
Copy-Item D:\Scripts\deploy.cmd -Destination e:\conf\deploy.cmd Copy-Item D:\Scripts\deploy.cmd -Destination e:\conf\deploy.cmd
mkdir e:\Tools\Scripts mkdir e:\Tools\Scripts
Copy-item d:\Scripts\Guests\SRV-01.ps1 E:\Tools\scripts\boot.ps1 Copy-item d:\Scripts\Guests\SRV-01.ps1 E:\Tools\scripts\boot.ps1
=======
Copy-Item d:\Unattend\server.xml -Destination e:\Windows\Panther\Unattend.xml
mkdir e:\Tools\Scripts
mkdir "e:\Program Files\BGINFO"
Copy-item d:\Scripts\Guests\SRV-01.ps1 E:\Tools\scripts\boot.ps1
Copy-Item D:\Soft\BGInfo_Deploiement\BGInfo64.exe "e:\Program Files\BGINFO\"
Copy-Item D:\Soft\BGInfo_Deploiement\mescouilles2.bgi "e:\Program Files\BGINFO\"
Copy-Item D:\Soft\BGInfo_Deploiement\bginfo.bat "e:\Program Files\BGINFO\"
>>>>>>> DNS
Dismount-VHD d:\VHD\SRV-01.vhdx Dismount-VHD d:\VHD\SRV-01.vhdx
$vms = @{ $vms = @{
@ -49,24 +40,12 @@ Set-VMNetworkAdapter -VMName 'SRV-01' -Name "Arc-SRV" -DeviceNaming on
echo "Adding and configuring SRV-03" echo "Adding and configuring SRV-03"
cp D:\VHD\Base\Base_SRV_diff.vhdx D:\VHD\SRV-03.vhdx cp D:\VHD\Base\Base_SRV_diff.vhdx D:\VHD\SRV-03.vhdx
<<<<<<< HEAD
Mount-VHD d:\VHD\SRV-03.vhdx |Get-Disk Mount-VHD d:\VHD\SRV-03.vhdx |Get-Disk
Copy-Item D:\Scripts\Unattend\FullUnattend-srv.xml -Destination e:\Windows\Panther\Unattend.xml Copy-Item D:\Scripts\Unattend\FullUnattend-srv.xml -Destination e:\Windows\Panther\Unattend.xml
Copy-Item D:\Scripts\deploy.cmd -Destination e:\conf\deploy.cmd Copy-Item D:\Scripts\deploy.cmd -Destination e:\conf\deploy.cmd
mkdir e:\Tools\Scripts mkdir e:\Tools\Scripts
#Copy-item d:\Scripts\Guests\SRV-03.ps1 E:\Tools\scripts\boot.ps1 #Copy-item d:\Scripts\Guests\SRV-03.ps1 E:\Tools\scripts\boot.ps1
Dismount-VHD d:\VHD\SRV-03.vhdx Dismount-VHD d:\VHD\SRV-03.vhdx
=======
Mount-VHD d:\VHD\SRV-03.vhdx
Copy-Item d:\Unattend\server.xml -Destination e:\Windows\Panther\Unattend.xml
mkdir e:\Tools\Scripts
mkdir "e:\Program Files\BGINFO"
Copy-item d:\Scripts\Guests\SRV-03.ps1 E:\Tools\scripts\boot.ps1
Copy-Item D:\Soft\BGInfo_Deploiement\BGInfo64.exe "e:\Program Files\BGINFO\"
Copy-Item D:\Soft\BGInfo_Deploiement\mescouilles2.bgi "e:\Program Files\BGINFO\"
Copy-Item D:\Soft\BGInfo_Deploiement\bginfo.bat "e:\Program Files\BGINFO\"
Dismount-VHD d:\VHD\SRV-01.vhdx
>>>>>>> DNS
$vms = @{ $vms = @{
@ -75,24 +54,17 @@ $vms = @{
MemoryStartupBytes = 1024Mb MemoryStartupBytes = 1024Mb
VHDPath = "d:\VHD\SRV-03.vhdx" VHDPath = "d:\VHD\SRV-03.vhdx"
SwitchName = "Bou-LAN" SwitchName = "Bou-LAN"
<<<<<<< HEAD
} }
=======
>>>>>>> DNS
New-VM @vms New-VM @vms
Set-VMMemory SRV-03 -DynamicMemoryEnabled $true -MinimumBytes 512MB -StartupBytes 1024MB -MaximumBytes 2GB Set-VMMemory SRV-03 -DynamicMemoryEnabled $true -MinimumBytes 512MB -StartupBytes 1024MB -MaximumBytes 2GB
Set-VM -Name SRV-03 -ProcessorCount 2 Set-VM -Name SRV-03 -ProcessorCount 2
echo "Configuring adapters" echo "Configuring adapters"
<<<<<<< HEAD
Rename-VMNetworkAdapter -VMName 'SRV-03' -NewName 'Bou-LAN' Rename-VMNetworkAdapter -VMName 'SRV-03' -NewName 'Bou-LAN'
Set-VMNetworkAdapter -VMName 'SRV-03' -Name "Bou-Lan" -DeviceNaming on Set-VMNetworkAdapter -VMName 'SRV-03' -Name "Bou-Lan" -DeviceNaming on
=======
Rename-VMNetworkAdapter -VMName 'SRV-03' -NewName 'Arc-SRV'
Set-VMNetworkAdapter -VMName 'SRV-03' -Name "Arc-SRV" -DeviceNaming on
>>>>>>> DNS
### Adding and configuring RTR-01 ### Adding and configuring RTR-01
@ -100,20 +72,12 @@ echo "Adding and configuring RTR-01"
cp D:\VHD\Base\Base_SRV_diff.vhdx D:\VHD\RTR-01.vhdx cp D:\VHD\Base\Base_SRV_diff.vhdx D:\VHD\RTR-01.vhdx
Mount-VHD d:\VHD\RTR-01.vhdx Mount-VHD d:\VHD\RTR-01.vhdx
<<<<<<< HEAD
Copy-Item D:\Scripts\Unattend\FullUnattend-srv.xml -Destination e:\Windows\Panther\Unattend.xml Copy-Item D:\Scripts\Unattend\FullUnattend-srv.xml -Destination e:\Windows\Panther\Unattend.xml
Copy-Item D:\Scripts\deploy.cmd -Destination e:\conf\deploy.cmd Copy-Item D:\Scripts\deploy.cmd -Destination e:\conf\deploy.cmd
mkdir e:\Tools\Scripts mkdir e:\Tools\Scripts
Copy-item d:\Scripts\Guests\RTR-01.ps1 E:\Tools\scripts\boot.ps1 Copy-item d:\Scripts\Guests\RTR-01.ps1 E:\Tools\scripts\boot.ps1
=======
Copy-Item d:\Unattend\server.xml -Destination e:\Windows\Panther\Unattend.xml
mkdir e:\Tools\Scripts
mkdir "e:\Program Files\BGINFO"
Copy-item d:\Scripts\Guests\RTR-01.ps1 E:\Tools\scripts\boot.ps1
Copy-Item D:\Soft\BGInfo_Deploiement\BGInfo64.exe "e:\Program Files\BGINFO\"
Copy-Item D:\Soft\BGInfo_Deploiement\mescouilles2.bgi "e:\Program Files\BGINFO\"
Copy-Item D:\Soft\BGInfo_Deploiement\bginfo.bat "e:\Program Files\BGINFO\"
>>>>>>> DNS
Dismount-VHD d:\VHD\RTR-01.vhdx Dismount-VHD d:\VHD\RTR-01.vhdx
$vms = @{ $vms = @{
@ -143,20 +107,12 @@ echo "Adding and configuring RTR-02"
cp D:\VHD\Base\Base_SRV_diff.vhdx D:\VHD\RTR-02.vhdx cp D:\VHD\Base\Base_SRV_diff.vhdx D:\VHD\RTR-02.vhdx
Mount-VHD d:\VHD\RTR-02.vhdx Mount-VHD d:\VHD\RTR-02.vhdx
<<<<<<< HEAD
Copy-Item D:\Scripts\Unattend\FullUnattend-srv.xml -Destination e:\Windows\Panther\Unattend.xml Copy-Item D:\Scripts\Unattend\FullUnattend-srv.xml -Destination e:\Windows\Panther\Unattend.xml
Copy-Item D:\Scripts\deploy.cmd -Destination e:\conf\deploy.cmd Copy-Item D:\Scripts\deploy.cmd -Destination e:\conf\deploy.cmd
mkdir e:\Tools\Scripts mkdir e:\Tools\Scripts
Copy-item D:\scripts\Guests\RTR-02.ps1 E:\Tools\scripts\boot.ps1 Copy-item D:\scripts\Guests\RTR-02.ps1 E:\Tools\scripts\boot.ps1
=======
Copy-Item d:\Unattend\server.xml -Destination e:\Windows\Panther\Unattend.xml
mkdir e:\Tools\Scripts
mkdir "e:\Program Files\BGINFO"
Copy-item D:\scripts\Guests\RTR-02.ps1 E:\Tools\scripts\boot.ps1
Copy-Item D:\Soft\BGInfo_Deploiement\BGInfo64.exe "e:\Program Files\BGINFO\"
Copy-Item D:\Soft\BGInfo_Deploiement\mescouilles2.bgi "e:\Program Files\BGINFO\"
Copy-Item D:\Soft\BGInfo_Deploiement\bginfo.bat "e:\Program Files\BGINFO\"
>>>>>>> DNS
Dismount-VHD d:\VHD\RTR-02.vhdx Dismount-VHD d:\VHD\RTR-02.vhdx
$vms = @{ $vms = @{
@ -186,20 +142,12 @@ echo "Adding and configuring RTR-03"
cp D:\VHD\Base\Base_SRV_diff.vhdx D:\VHD\RTR-03.vhdx cp D:\VHD\Base\Base_SRV_diff.vhdx D:\VHD\RTR-03.vhdx
Mount-VHD d:\VHD\RTR-03.vhdx Mount-VHD d:\VHD\RTR-03.vhdx
<<<<<<< HEAD
Copy-Item D:\Scripts\Unattend\FullUnattend-srv.xml -Destination e:\Windows\Panther\Unattend.xml Copy-Item D:\Scripts\Unattend\FullUnattend-srv.xml -Destination e:\Windows\Panther\Unattend.xml
Copy-Item D:\Scripts\deploy.cmd -Destination e:\conf\deploy.cmd Copy-Item D:\Scripts\deploy.cmd -Destination e:\conf\deploy.cmd
mkdir e:\Tools\Scripts mkdir e:\Tools\Scripts
Copy-item d:\Scripts\Guests\RTR-03.ps1 E:\Tools\scripts\boot.ps1 Copy-item d:\Scripts\Guests\RTR-03.ps1 E:\Tools\scripts\boot.ps1
=======
Copy-Item d:\Unattend\server.xml -Destination e:\Windows\Panther\Unattend.xml
mkdir e:\Tools\Scripts
mkdir "e:\Program Files\BGINFO"
Copy-item d:\Scripts\Guests\RTR-03.ps1 E:\Tools\scripts\boot.ps1
Copy-Item D:\Soft\BGInfo_Deploiement\BGInfo64.exe "e:\Program Files\BGINFO\"
Copy-Item D:\Soft\BGInfo_Deploiement\mescouilles2.bgi "e:\Program Files\BGINFO\"
Copy-Item D:\Soft\BGInfo_Deploiement\bginfo.bat "e:\Program Files\BGINFO\"
>>>>>>> DNS
Dismount-VHD d:\VHD\RTR-03.vhdx Dismount-VHD d:\VHD\RTR-03.vhdx
$vms = @{ $vms = @{
@ -228,10 +176,8 @@ Start-VM -Name RTR*
### Sleeping 30s ### Sleeping 30s
echo "Sleeping 30" echo "Sleeping 30"
<<<<<<< HEAD
Sleep 130
=======
Sleep 30 Sleep 30
>>>>>>> DNS
Start-VM -Name SRV* Start-VM -Name SRV*

View File

@ -60,3 +60,27 @@ Rename-Netadapter -name $adapt.name -NewName $HWName
### Set DNS Server on client ### Set DNS Server on client
Set-DnsClientServerAddress -InterfaceIndex 7 -ServerAddresses ("10.152.0.6", "10.152.0.7") Set-DnsClientServerAddress -InterfaceIndex 7 -ServerAddresses ("10.152.0.6", "10.152.0.7")
### DNS avec variables via https://www.sapien.com/forums/viewtopic.php?t=14700
$DomainNames = 'CorporateProduct1.com'
$PrimaryDNSServer = 'PRDSVRDNS01-VM'
$SecondaryDNSServer1 = 'PRDSVRDNS02-VM'
$SecondaryDNSServer2 = 'PRDSVRDNS03-VM'
#Create Primary DNS Forward Lookup Zone
Add-DnsServerPrimaryZone -ComputerName $PrimaryDNSServer -Name $DomainNames -ZoneFile $DomainNames.dns -DynamicUpdate None -ResponsiblePerson "domains.$($ENV:USERDNSDOMAIN.ToLower())"
Set-DnsServerPrimaryZone -ComputerName $PrimaryDNSServer -Name $DomainNames -SecureSecondaries "TransferToSecureServers" -SecondaryServers "$([System.Net.Dns]::GetHostAddresses($SecondaryDNSServer1).IPAddressToString)", "$([System.Net.Dns]::GetHostAddresses($SecondaryDNSServer2).IPAddressToString)"
# Set the Public DNS servers to replicate to
Add-DnsServerResourceRecord -ComputerName $PrimaryDNSServer -Name '@' -ZoneName $DomainNames -NS -NameServer "ns1.$ENV:USERDNSDOMAIN"
Add-DnsServerResourceRecord -ComputerName $PrimaryDNSServer -Name '@' -ZoneName $DomainNames -NS -NameServer "ns2.$ENV:USERDNSDOMAIN"
Add-DnsServerResourceRecord -ComputerName $PrimaryDNSServer -Name '@' -ZoneName $DomainNames -NS -NameServer "ns3.$ENV:USERDNSDOMAIN"
#Let the Forward lookup zones created completely
Start-Sleep -Seconds 5
#Replicate the Forwardlookup zones into two additional Public DNS servers
Add-DnsServerSecondaryZone -ComputerName $SecondaryDNSServer1 -MasterServers [System.Net.Dns]::GetHostAddresses($PrimaryDNSServer).IPAddressToString -Name $DomainNames -ZoneFile "$DomainNames.dns"
Add-DnsServerSecondaryZone -ComputerName $SecondaryDNSServer2 -MasterServers [System.Net.Dns]::GetHostAddresses($PrimaryDNSServer).IPAddressToString -Name $DomainNames -ZoneFile "$DomainNames.dns"