2021-06-01 16:47:36 +02:00
# Alexandre Simao
2021-05-31 14:43:26 +02:00
# GPL v3
2021-06-01 16:47:36 +02:00
# SRV-03 ONLY
# asrbd.dev,asrbd.local,dev.asrbd.local
# TODO:
2021-05-31 14:43:26 +02:00
echo " Shamefully made by Alexandre Simao. Pardon-me M. Stallman "
### Rename this piece of garbage
echo " Changing Computer's name "
2021-06-01 16:47:36 +02:00
Rename-computer " SRV-03 "
2021-05-31 14:43:26 +02:00
# 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
2021-06-01 16:47:36 +02:00
netsh interface ip set address name = " Bou-LAN " static 192.168 . 128 . 1 255.255 . 255 . 0 192.168 . 128 . 254
2021-05-31 14:43:26 +02:00
### DNS Conf for all InterfaceAlias ###
echo " DNS Conf "
2021-06-01 16:47:36 +02:00
foreach ( $c in Get-NetAdapter ) { write-host 'Setting DNS for' $c . interfaceName ; Set-DnsClientServerAddress -InterfaceIndex $c . interfaceindex -ServerAddresses ( '192.168.8.1' ) }
2021-05-31 14:43:26 +02:00
### Setting connection as Private
echo " Setting connection as Private "
Set-NetConnectionProfile -NetworkCategory Private
### Change ZoneAlarm rule to accept incoming ICMP ipv4 probes
echo " Allowing ICMPv4 probes "
$Params = @ {
" Name " = 'vm-monitoring-icmpv4'
" Action " = 'Allow'
}
Set-NetFirewallRule @Params
# END
2021-06-01 16:47:36 +02:00
### Add routes for RTR-03
2021-06-01 10:18:07 +02:00
2021-06-01 16:47:36 +02:00
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
2021-06-01 10:18:07 +02:00
2021-06-01 16:47:36 +02:00
# END
2021-06-01 10:18:07 +02:00
2021-06-01 16:47:36 +02:00
### Installing and configuring DNS role
2021-06-01 10:18:07 +02:00
2021-06-01 16:47:36 +02:00
# Install and configure DNS server
2021-06-01 10:18:07 +02:00
2021-06-01 16:47:36 +02:00
Install-WindowsFeature -Name DNS -IncludeManagementTools -includeallsubfeature #
2021-06-01 10:18:07 +02:00
2021-06-01 16:47:36 +02:00
#Add-DnsServerPrimaryZone -NetworkID 192.168.128.0/24 -ZoneFile “192.168.128.1.in-addr.arpa.dns” # Zone secondaire
2021-06-01 10:18:07 +02:00
2021-06-01 16:47:36 +02:00
Set-DnsServerPrimaryZone -ComputerName SRV - 03 -Name asrbd . dev -SecureSecondaries " TransferToSecureServers " -SecondaryServers " 192.168.8.1 "
2021-06-01 10:18:07 +02:00
2021-06-01 16:47:36 +02:00
Add-DnsServerPrimaryZone -ResponsiblePerson " bol@loc.ks " -DynamicUpdate None -ZoneFile asrbd . dev . dns -Name asrbd . dev
2021-06-01 10:18:07 +02:00
2021-06-01 16:47:36 +02:00
$ns = Get-DnsServerResourceRecord -ZoneName asrbd . dev -RRType NS
2021-06-01 10:18:07 +02:00
2021-06-01 16:47:36 +02:00
$nsnew = $ns . Clone ( )
2021-06-01 10:18:07 +02:00
2021-06-01 16:47:36 +02:00
$nsnew . RecordData . NameServer = " srv-03.asrbd.dev "
2021-06-01 10:18:07 +02:00
2021-06-01 16:47:36 +02:00
# Get-DnsServerZone -Name asrbd.dev
2021-06-01 10:18:07 +02:00
2021-06-01 16:47:36 +02:00
Set-DnsServerResourceRecord -ZoneName asrbd . dev -NewInputObject $nsnew -OldInputObject $ns
2021-06-01 10:18:07 +02:00
2021-06-01 16:47:36 +02:00
$soa = Get-DnsServerResourceRecord -ZoneName asrbd . dev -RRType Soa
2021-06-01 10:18:07 +02:00
2021-06-01 16:47:36 +02:00
$soanew = $soa . Clone ( )
2021-06-01 10:18:07 +02:00
2021-06-01 16:47:36 +02:00
$soanew . RecordData . PrimaryServer = " srv-03.asrbd.dev "
$soanew . RecordData . ExpireLimit = ( New-TimeSpan -Days 4 )
2021-06-01 10:18:07 +02:00
2021-06-01 16:47:36 +02:00
Set-DnsServerResourceRecord -ZoneName as -NewInputObject $soanew -OldInputObject $soa
2021-06-01 10:18:07 +02:00
2021-06-01 16:47:36 +02:00
Set-DnsServerPrimaryZone -ComputerName SRV - 01 -Name asrbd . dev -SecureSecondaries " TransferToSecureServers " -SecondaryServers " 192.168.128.1 "
2021-06-01 10:18:07 +02:00
2021-06-01 11:40:58 +02:00
Add-DnsServerForwarder -IPAddress 9.9 . 9 . 9 -PassThru # Forward
2021-06-01 10:18:07 +02:00
2021-06-01 16:47:36 +02: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
2021-06-01 10:18:07 +02:00
2021-06-01 11:40:58 +02: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 "
2021-06-01 16:47:36 +02:00
Read-Host " DNS Tests "
2021-06-01 10:18:07 +02:00
# Add BGINFO autostart
C: \ Program Files \ BGINFO \ Bginfo64 . exe mescouilles2 . bgi / all / nolicprompt
Read-Host " Finished? "
Restart-Computer