Feat: DNS

This commit is contained in:
Winston Smith 2021-06-02 14:26:00 +02:00
parent a98ccebe62
commit dcdfdb658f
2 changed files with 70 additions and 31 deletions

View File

@ -2,7 +2,7 @@
# GPL v3
# SRV-01 ONLY
# asrbd.local domain
# asrc.local domain
# TODO: Delegation
@ -125,32 +125,33 @@ Get-DhcpServerv4Scope | Set-DhcpServerv4OptionValue -DnsServer 192.168.128.1,192
Install-WindowsFeature -Name DNS -IncludeManagementTools -includeallsubfeature
#Create asrbd.local zone
Set-DnsServerPrimaryZone -ComputerName SRV-01 -Name "asrbd.local" -SecureSecondaries "TransferToSecureServers" -SecondaryServers "192.168.128.1"
#Create asrc.local zone
Add-DnsServerPrimaryZone -ResponsiblePerson bol@loc.ks -DynamicUpdate None -ZoneFile asrbd.local.dns -Name asrbd.local
Add-DnsServerPrimaryZone -ResponsiblePerson bol@loc.ks -DynamicUpdate None -ZoneFile asrc.local.dns -Name asrc.local
Set-DnsServerPrimaryZone -ComputerName SRV-01 -Name "asrc.local" -SecureSecondaries "TransferToSecureServers" -SecondaryServers "192.168.128.1"
#Rename SOA+NS Main Zone
$ns = Get-DnsServerResourceRecord -ZoneName "asrbd.local" -RRType NS
$ns = Get-DnsServerResourceRecord -ZoneName "asrc.local" -RRType NS
$nsnew = $ns.Clone()
$nsnew.RecordData.NameServer = "srv-01.asrbd.local"
$nsnew.RecordData.NameServer = "srv-01.asrc.local"
Set-DnsServerResourceRecord -ZoneName asrbd.local -NewInputObject $nsnew -OldInputObject $ns
Set-DnsServerResourceRecord -ZoneName asrc.local -NewInputObject $nsnew -OldInputObject $ns
$soa = Get-DnsServerResourceRecord -ZoneName asrbd.local -RRType Soa
$soa = Get-DnsServerResourceRecord -ZoneName asrc.local -RRType Soa
$soanew = $soa.Clone()
$soanew.RecordData.PrimaryServer = "srv-01.asrbd.local"
$soanew.RecordData.PrimaryServer = "srv-01.asrc.local"
$soanew.RecordData.ExpireLimit = (New-TimeSpan -Days 4)
Set-DnsServerResourceRecord -ZoneName asrbd.local -NewInputObject $soanew -OldInputObject $soa
Set-DnsServerResourceRecord -ZoneName asrc.local -NewInputObject $soanew -OldInputObject $soa
#Set zone transfer
Set-DnsServerPrimaryZone -ComputerName SRV-01 -Name asrbd.local -SecureSecondaries "TransferToSecureServers" -SecondaryServers "192.168.128.1"
Set-DnsServerPrimaryZone -ComputerName SRV-01 -Name asrc.local -SecureSecondaries "TransferToSecureServers" -SecondaryServers "192.168.128.1"
#Create reverse lookup Zone
Add-DnsServerPrimaryZone -NetworkID "192.168.0.0/16" -Zonefile "168.192.in-addr.arpa.dns"
@ -160,7 +161,7 @@ $ns = Get-DnsServerResourceRecord -ZoneName 168.192.in-addr.arpa -RRType NS
$nsnew = $ns.Clone()
$nsnew.RecordData.NameServer = "srv-01.asrbd.local"
$nsnew.RecordData.NameServer = "srv-01.asrc.local"
Set-DnsServerResourceRecord -ZoneName 168.192.in-addr.arpa -NewInputObject $nsnew -OldInputObject $ns
@ -168,16 +169,28 @@ $soa = Get-DnsServerResourceRecord -ZoneName 168.192.in-addr.arpa -RRType Soa
$soanew = $soa.Clone()
$soanew.RecordData.PrimaryServer = "srv-01.asrbd.local"
$soanew.RecordData.PrimaryServer = "srv-01.asrc.local"
$soanew.RecordData.ExpireLimit = (New-TimeSpan -Days 4)
Set-DnsServerResourceRecord -ZoneName asrbd.local -NewInputObject $soanew -OldInputObject $soa
Set-DnsServerResourceRecord -ZoneName asrc.local -NewInputObject $soanew -OldInputObject $soa
#Set DNS forwarder
# Set DNS SRV-03 forwarder
Add-DnsServerConditionalForwarderZone -Name "asrc.devs" -MasterServers 192.168.128.1 -PassThru
Add-DnsServerConditionalForwarderZone -Name "devs.asrc.devs" -MasterServers 192.168.128.1 -PassThru
# Set DNS net forwarder
Add-DnsServerForwarder -IPAddress 9.9.9.9 -PassThru # Forward
Add-DnsServerResourceRecordA -Name "SRV-01" -ZoneName "asrbd.local" -IPv4Address "192.168.8.1" -TimeToLive 01:00:00
Add-DnsServerResourceRecordA -Name "SRV-02" -ZoneName "asrbd.local" -IPv4Address "192.168.8.2" -TimeToLive 01:00:00
# Add records
Add-DnsServerResourceRecordA -Name "srv-01" -ZoneName "asrc.local" -IPv4Address "192.168.8.1" -TimeToLive 01:00:00 -CreatePTR
Add-DnsServerResourceRecordA -Name "srv-02" -ZoneName "asrc.local" -IPv4Address "192.168.8.2" -TimeToLive 01:00:00 -CreatePTR
Add-DnsServerResourceRecordA -Name "srv-03" -ZoneName "asrc.local" -IPv4Address "192.168.128.1" -TimeToLive 01:00:00 -CreatePTR
Add-DnsServerResourceRecord -ZoneName "asrc.local" -NS -Name asrc.local -Nameserver "srv-03.asrc.local."
#Add-DnsServerResourceRecord -ZoneName "asrc.local" -A -Name dev.asrc.local -IPv4Address "192.168.128.1"
Add-DnsServerZoneTransferPolicy -Name "asrc.local" -Action IGNORE -ServerInterfaceIP "ne,192.168.128.1" -PassThru -ZoneName "asrc.local"
#Add-DnsServerZoneDelegation -Name "asrc.local" -ChildZoneName "dev" -NameServer "srv-03.asrc.local." -IPAddress 192.168.128.1 -PassThru -Verbose
# Add local DNS for all Hosts

View File

@ -2,7 +2,7 @@
# GPL v3
# SRV-03 ONLY
# asrbd.dev,asrbd.local,dev.asrbd.local
# asrc.dev,asrc.local,dev.asrc.local
# TODO:
@ -76,35 +76,61 @@ Install-WindowsFeature -Name DNS -IncludeManagementTools -includeallsubfeature
#Add-DnsServerPrimaryZone -NetworkID 192.168.128.0/24 -ZoneFile “192.168.128.1.in-addr.arpa.dns” # Zone secondaire
Set-DnsServerPrimaryZone -ComputerName SRV-03 -Name asrbd.dev -SecureSecondaries "TransferToSecureServers" -SecondaryServers "192.168.8.1"
#Create asrc.dev
Add-DnsServerPrimaryZone -ResponsiblePerson "bol@loc.ks" -DynamicUpdate None -ZoneFile asrbd.dev.dns -Name asrbd.dev
Set-DnsServerPrimaryZone -ComputerName SRV-03 -Name asrc.dev -SecureSecondaries "TransferToSecureServers" -SecondaryServers "192.168.8.1"
$ns = Get-DnsServerResourceRecord -ZoneName asrbd.dev -RRType NS
Add-DnsServerPrimaryZone -ResponsiblePerson "bol@loc.ks" -DynamicUpdate None -ZoneFile asrc.dev.dns -Name asrc.dev
$ns = Get-DnsServerResourceRecord -ZoneName asrc.dev -RRType NS
$nsnew = $ns.Clone()
$nsnew.RecordData.NameServer = "srv-03.asrbd.dev"
$nsnew.RecordData.NameServer = "srv-03.asrc.dev"
# Get-DnsServerZone -Name asrbd.dev
Set-DnsServerResourceRecord -ZoneName asrc.dev -NewInputObject $nsnew -OldInputObject $ns
Set-DnsServerResourceRecord -ZoneName asrbd.dev -NewInputObject $nsnew -OldInputObject $ns
$soa = Get-DnsServerResourceRecord -ZoneName asrbd.dev -RRType Soa
$soa = Get-DnsServerResourceRecord -ZoneName asrc.dev -RRType Soa
$soanew = $soa.Clone()
$soanew.RecordData.PrimaryServer = "srv-03.asrbd.dev"
$soanew.RecordData.PrimaryServer = "srv-03.asrc.dev"
$soanew.RecordData.ExpireLimit = (New-TimeSpan -Days 4)
Set-DnsServerResourceRecord -ZoneName asrbd.dev -NewInputObject $soanew -OldInputObject $soa
Set-DnsServerResourceRecord -ZoneName asrc.dev -NewInputObject $soanew -OldInputObject $soa
#Create dev.asrc.local
Set-DnsServerPrimaryZone -ComputerName SRV-03 -Name asrc.dev -SecureSecondaries "TransferToSecureServers" -SecondaryServers "192.168.8.1"
Add-DnsServerPrimaryZone -ResponsiblePerson "bol@loc.ks" -DynamicUpdate None -ZoneFile asrc.dev.dns -Name asrc.dev
$ns = Get-DnsServerResourceRecord -ZoneName asrc.dev -RRType NS
$nsnew = $ns.Clone()
$nsnew.RecordData.NameServer = "srv-03.dev.asrc.local"
Set-DnsServerResourceRecord -ZoneName asrc.dev -NewInputObject $nsnew -OldInputObject $ns
$soa = Get-DnsServerResourceRecord -ZoneName dev.asrc.local -RRType Soa
$soanew = $soa.Clone()
$soanew.RecordData.PrimaryServer = "srv-03.dev.asrc.local"
$soanew.RecordData.ExpireLimit = (New-TimeSpan -Days 4)
Set-DnsServerResourceRecord -ZoneName dev.asrc.local -NewInputObject $soanew -OldInputObject $soa
Set-DnsServerPrimaryZone -ComputerName SRV-01 -Name asrbd.dev -SecureSecondaries "TransferToSecureServers" -SecondaryServers "192.168.128.1"
Add-DnsServerForwarder -IPAddress 9.9.9.9 -PassThru # Forward
Add-DnsServerResourceRecordA -Name "SRV-01" -ZoneName "asrbd.dev" -IPv4Address "192.168.8.1" -TimeToLive 01:00:00
Add-DnsServerResourceRecordA -Name "SRV-02" -ZoneName "asrbd.dev" -IPv4Address "192.168.8.2" -TimeToLive 01:00:00
Add-DnsServerResourceRecordA -Name "SRV-03" -ZoneName "dev.asrc.local" -IPv4Address "192.168.128.1" -TimeToLive 01:00:00
#Add DNS secondary zone for asrc.local
Add-DnsServerSecondaryZone -Name "asrc.local" -ZoneFile "asrc.local.dns" -MasterServers 192.168.8.1
Start-DnsServerZoneTransfer -Name "asrc.local"
Read-Host "Finished?"
Restart-Computer