Feat: Add basic DNS to SRV-03

This commit is contained in:
Alexandre-Simao 2021-06-01 16:47:36 +02:00
parent 7ce08077f8
commit aef16c0956
2 changed files with 38 additions and 100 deletions

View File

@ -126,6 +126,7 @@ Get-DhcpServerv4Scope | Set-DhcpServerv4OptionValue -DnsServer 192.168.128.1,192
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
Set-DnsServerPrimaryZone -ComputerName SRV-01 -Name asrbd.local -SecureSecondaries "TransferToSecureServers" -SecondaryServers "192.168.128.1"
Add-DnsServerPrimaryZone -ResponsiblePerson "bol@loc.ks" -DynamicUpdate None -ZoneFile asrbd.local.dns -Name asrbd.local

View File

@ -1,96 +1,8 @@
# Alexandre Simao
# Alexandre Simao
# GPL v3
# SRV-01 ONLY
# TODO : exclusion/attribution fields
# Rename interfaces
#
echo "Shamefully made by Alexandre Simao. Pardon-me M. Stallman"
### Rename this piece of garbage
echo "Changing Computer's name"
Rename-computer "SRV-1"
# End
### Rename interfaces by parsing VM device name
echo "Renaming adapters"
$adapts = Get-NetAdapter
foreach ($adapt in $adapts) {
$HVName = (Get-NetAdapterAdvancedProperty -name $adapt.name -DisplayName "Hyper-v Network Adapter Name").DisplayValue
Rename-Netadapter -name $adapt.name -NewName $HVName
}
#End
# Pausing to let things settle
echo "Sleeping 10s"
Sleep 10
### Général IP configure
# echo "IP configuration"
#Arc-SRV
netsh interface ip set address name="Arc-SRV" static 192.168.8.1 255.255.255.0 192.168.8.254
### DNS Conf for all InterfaceAlias ###
echo "DNS Conf"
foreach ($c in Get-NetAdapter) { write-host 'Setting DNS for' $c.interfaceName ; Set-DnsClientServerAddress -InterfaceIndex $c.interfaceindex -ServerAddresses ('192.168.8.1,192.168.128.1') }
#END
### Setting connection as Private
echo "Setting connection as Private"
Set-NetConnectionProfile -NetworkCategory Private
###################Template#######################
#Add-DhcpServerv4Scope -name "Corpnet" -StartRange 10.0.0.1 -EndRange 10.0.0.254 -SubnetMask 255.255.255.0 -State Active
#Add-DhcpServerv4ExclusionRange -ScopeID 10.0.0.0 -StartRange 10.0.0.1 -EndRange 10.0.0.15
#Set-DhcpServerv4OptionValue -OptionID 3 -Value 10.0.0.1 -ScopeID 10.0.0.0 -ComputerName DHCP1.corp.contoso.com
#Set-DhcpServerv4OptionValue -DnsDomain corp.contoso.com -DnsServer 10.0.0.2
##################################################
### Change ZoneAlarm rule to accept incoming ICMP ipv4 probes
echo "Allowing ICMPv4 probes"
$Params = @{
"Name" = 'vm-monitoring-icmpv4'
"Action" = 'Allow'
}
Set-NetFirewallRule @Params
# END
### 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.255.0/24 192.168.8.254
route add -p 192.168.128.0/24 192.168.8.254
route add -p 0.0.0.0/0 192.168.8.254
# END
### Change DHCP server options
echo "Adding DHCP server options"
Set-DhcpServerv4OptionValue -ScopeId 192.168.128.0 -Router 192.168.128.254
Set-DhcpServerv4OptionValue -ScopeId 192.168.12.0 -Router 192.168.12.254
Set-DhcpServerv4OptionValue -ScopeId 192.168.8.0 -Router 192.168.8.254
Get-DhcpServerv4Scope | Set-DhcpServerv4OptionValue -DnsServer 192.168.8.1
Read-Host "Finished?"
Restart-Computer
=======
# Alexandre Simao
# GPL v3
# SRV-01 ONLY
# asrbd.local domain
# SRV-03 ONLY
# asrbd.dev,asrbd.local,dev.asrbd.local
# TODO:
@ -145,14 +57,15 @@ $Params = @{
Set-NetFirewallRule @Params
# END
### Add routes for RTR-01
### Add routes for RTR-03
echo "Add routes for RTR-01"
echo "Add routes for RTR-03"
route add -p 192.168.8.0/24 192.168.128.254
route add -p 192.168.12.0/24 192.168.128.254
route add -p 192.168.255.0/24 192.168.128.254
route add -p 0.0.0.0/0 192.168.128.254
# END
# END
### Installing and configuring DNS role
@ -161,22 +74,46 @@ route add -p 0.0.0.0/0 192.168.128.254
Install-WindowsFeature -Name DNS -IncludeManagementTools -includeallsubfeature#
#Add-DnsServerPrimaryZone -NetworkID 192.168.128.0/24 -ZoneFile “192.168.8.1.in-addr.arpa.dns” # Zone secondaire
Add-DnsServerPrimaryZone -Name "asrbd.dev" -ZoneFile "asrbd.dev.dns" -DynamicUpdate None
Add-DnsServerPrimaryZone -Name "dev.asrbd.local" -ZoneFile "dev.asrbd.local.dns"
#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"
Add-DnsServerPrimaryZone -ResponsiblePerson "bol@loc.ks" -DynamicUpdate None -ZoneFile asrbd.dev.dns -Name asrbd.dev
$ns = Get-DnsServerResourceRecord -ZoneName asrbd.dev -RRType NS
$nsnew = $ns.Clone()
$nsnew.RecordData.NameServer = "srv-03.asrbd.dev"
# Get-DnsServerZone -Name asrbd.dev
Set-DnsServerResourceRecord -ZoneName asrbd.dev -NewInputObject $nsnew -OldInputObject $ns
$soa = Get-DnsServerResourceRecord -ZoneName asrbd.dev -RRType Soa
$soanew = $soa.Clone()
$soanew.RecordData.PrimaryServer = "srv-03.asrbd.dev"
$soanew.RecordData.ExpireLimit = (New-TimeSpan -Days 4)
Set-DnsServerResourceRecord -ZoneName as -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-03" -ZoneName "asrbd.dev" -IPv4Address "192.168.128.1" -TimeToLive 01:00:00
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
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"
Read-Host "DNS Tests"
# Add BGINFO autostart
C:\Program Files\BGINFO\Bginfo64.exe mescouilles2.bgi /all /nolicprompt
Read-Host "Finished?"
Restart-Computer
>>>>>>> DNS