-
Notifications
You must be signed in to change notification settings - Fork 0
/
Windows-Conditional-DNS.ps1
29 lines (21 loc) · 1.07 KB
/
Windows-Conditional-DNS.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# Perform the below using Powershell as Admnistrator
# Modify to match the VPC DNS IP
$VPCDNS = "172.17.1.2"
$Name = "DNS-Server"
$OnPremDNS = "10.0.0.1,10.0.0.2"
$DNSSuffix = "ec2.internal"
$ZoneForward = "onprem.local"
$ZoneReverse = "10.in-addr.arpa"
# Install DNS ServerAddresses
Install-WindowsFeature -Name DNS -IncludeAllSubFeature -IncludeManagementTools
# Set DNS Forwarder and do not use root hints
Add-DnsServerForwarder -IPAddress $VPCDNS -PassThru
Set-DnsServerForwarder -UseRootHint $false
# Create Conditional Zones
Add-DnsServerConditionalForwarderZone -Name $ZoneForward -MasterServers $OnPremDNS -PassThru
Add-DnsServerConditionalForwarderZone -Name $ZoneReverse -MasterServers $OnPremDNS -PassThru
#Update primary DNS Suffix for FQDN
Set-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\" -Name Domain -Value $DNSSuffix
Set-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\" -Name "NV Domain" -Value $DNSSuffix
# Rename Computer and Restart
Rename-Computer -NewName $Name -Restart -PassThru -Force