Feat: Switch to srv-01 DNS for all clients

This commit is contained in:
Alexandre S 2021-05-11 16:46:18 +02:00
parent b83b2638cd
commit 532691cecb
5 changed files with 23 additions and 16 deletions

View File

@ -3,9 +3,6 @@
# Script to install and configure a Fuckdows Server 2016 as a router
# RTR-01 Only
# Script done
echo "Shamefully made by Alexandre Simao. Pardon-me M. Stallman"
@ -54,7 +51,7 @@ netsh interface ip set address name="WAN" static 192.168.255.8 255.255.255.0 192
### 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 ('9.9.9.9') }
foreach ($c in Get-NetAdapter) { write-host 'Setting DNS for' $c.interfaceName ; Set-DnsClientServerAddress -InterfaceIndex $c.interfaceindex -ServerAddresses ('192.168.8.1') }
# End of scriptlet

View File

@ -50,8 +50,8 @@ echo "Done!"
### DNS Conf for all InterfaceAlias
echo "Configuring Dns for 9.9.9.9 on all interfaces"
foreach ($c in Get-NetAdapter) { write-host 'Setting DNS for' $c.interfaceName ; Set-DnsClientServerAddress -InterfaceIndex $c.interfaceindex -ServerAddresses ('9.9.9.9') }
echo "Configuring Dns for 192.168.8.1 on all interfaces"
foreach ($c in Get-NetAdapter) { write-host 'Setting DNS for' $c.interfaceName ; Set-DnsClientServerAddress -InterfaceIndex $c.interfaceindex -ServerAddresses ('192.168.8.1') }
echo "Done!"
#End

View File

@ -49,8 +49,8 @@ echo "Done!"
### DNS Conf for all InterfaceAlias
echo "Setting 9.9.9.9 as default DNS on all interfaces"
foreach ($c in Get-NetAdapter) { write-host 'Setting DNS for' $c.interfaceName ; Set-DnsClientServerAddress -InterfaceIndex $c.interfaceindex -ServerAddresses ('9.9.9.9') }
echo "Setting 192.168.8.1 as default DNS on all interfaces"
foreach ($c in Get-NetAdapter) { write-host 'Setting DNS for' $c.interfaceName ; Set-DnsClientServerAddress -InterfaceIndex $c.interfaceindex -ServerAddresses ('192.168.8.1') }
echo "Done!"
#End

View File

@ -11,7 +11,7 @@ echo "Shamefully made by Alexandre Simao. Pardon-me M. Stallman"
### Rename this piece of garbage
echo "Changing Computer's name"
Rename-computer "SRV-1"
Rename-computer "SRV-01"
# End
### Rename interfaces by parsing VM device name
@ -39,7 +39,7 @@ netsh interface ip set address name="Arc-SRV" static 192.168.8.1 255.255.255.0 1
### 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 ('9.9.9.9') }
foreach ($c in Get-NetAdapter) { write-host 'Setting DNS for' $c.interfaceName ; Set-DnsClientServerAddress -InterfaceIndex $c.interfaceindex -ServerAddresses ('192.168.8.1') }
### Install the DHCP role (Management tools if you love Metrosexual UI)
@ -118,9 +118,20 @@ 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
#Set-DhcpServerv4OptionValue -ScopeId 192.168.8.0 -DnsServer 9.9.9.9
#Set-DhcpServerv4OptionValue -ScopeId 192.168.8.0 -DnsServer 192.168.8.1
Get-DhcpServerv4Scope | Set-DhcpServerv4OptionValue -DnsServer 9.9.9.9
Get-DhcpServerv4Scope | Set-DhcpServerv4OptionValue -DnsServer 192.168.8.1
### Installing and configuring DNS role
Install-WindowsFeature -Name DNS -IncludeManagementTools -includeallsubfeature
#TWILIGHT ZONE
Add-DnsServerSecondaryZone -Name "bollocks.microdows.local" -ZoneFile "bollocks.dns" -MasterServers "192.168.8.1"
Add-DnsServerSecondaryZone -MasterServers "192.168.8.1" -Name "bollocks.microdows.local" -ZoneFile "bollocks.dns"
Add-DnsServerPrimaryZone -NetworkID 192.168.8.0/24 -ZoneFile 192.168.8.1.in-addr.arpa.dns # Zone secondaire
Add-DnsServerForwarder -IPAddress 192.168.8.1 -PassThru # Forward
Test-DnsServer -IPAddress 192.168.8.1 -ZoneName "www.darty.fr" #Test
Read-Host "Finished?"
Restart-Computer

View File

@ -15,10 +15,6 @@ $adapter | New-NetIPAddress `
-PrefixLength $MaskBits `
-DefaultGateway $Gateway
$IP = "10.10.10.10"
$MaskBits = 24 # This means subnet mask = 255.255.255.0
$Gateway = "10.10.10.1"
@ -53,3 +49,6 @@ foreach ($adapt in $adapts) {
$HWName = (Get-NetAdapterAdvancedProperty -name $adapt.name -DisplayName "Hyper-v Network Adapter Name").DisplayValue
Rename-Netadapter -name $adapt.name -NewName $HWName
}
### Set DNS Server on client
Set-DnsClientServerAddress -InterfaceIndex 7 -ServerAddresses ("10.152.0.6", "10.152.0.7")