Preserve DNS name lookup across CED and Sala Wi-Fi profiles
This commit is contained in:
1 parent
b9756ad3b2
commit
2cca02db35
2 files changed
+63
-3
No files matched your search
@@ -12,11 +12,23 @@ if (-not (Test-Path -LiteralPath $BackupPath)) {
|
||||
$client | Select-Object InterfaceAlias, ConnectionSpecificSuffix |
|
||||
ConvertTo-Json | Set-Content -LiteralPath $BackupPath -Encoding UTF8
|
||||
}
|
||||
Set-DnsClient -InterfaceAlias $InterfaceAlias -ConnectionSpecificSuffix 'lci.lasalle.mx'
|
||||
$rules = @(Get-DnsClientNrptRule | Where-Object { $_.Namespace -contains '.lci.lasalle.mx' })
|
||||
if ($rules.Count -gt 0 -and ($rules.Count -ne 1 -or $rules[0].NameServers -ne '192.168.54.211')) {
|
||||
throw 'An existing domain DNS rule needs review; it was not overwritten.'
|
||||
}
|
||||
$globalBefore = Get-DnsClientGlobalSetting
|
||||
$globalBackupPath = Join-Path (Split-Path $BackupPath) 'LCI77-DnsSearchList-before.json'
|
||||
if (-not (Test-Path -LiteralPath $globalBackupPath)) {
|
||||
$globalBefore | Select-Object SuffixSearchList | ConvertTo-Json |
|
||||
Set-Content -LiteralPath $globalBackupPath -Encoding UTF8
|
||||
}
|
||||
# DHCP connection suffixes can disappear when changing SSIDs. The explicit
|
||||
# search list is persistent and also preserves existing VPN/interface suffixes.
|
||||
$suffixes = @('lci.lasalle.mx') + @($globalBefore.SuffixSearchList) +
|
||||
@(Get-DnsClient | Select-Object -ExpandProperty ConnectionSpecificSuffix)
|
||||
$suffixes = @($suffixes | Where-Object { $_ } | Select-Object -Unique)
|
||||
Set-DnsClientGlobalSetting -SuffixSearchList $suffixes
|
||||
Set-DnsClient -InterfaceAlias $InterfaceAlias -ConnectionSpecificSuffix 'lci.lasalle.mx'
|
||||
if ($rules.Count -eq 0) {
|
||||
Add-DnsClientNrptRule -Namespace '.lci.lasalle.mx' -NameServers '192.168.54.211' -Comment 'CED domain DNS for local administrator Wi-Fi'
|
||||
}
|
||||
@@ -24,5 +36,7 @@ Clear-DnsClientCache
|
||||
[pscustomobject]@{
|
||||
Computer = $env:COMPUTERNAME
|
||||
Suffix = (Get-DnsClient -InterfaceAlias $InterfaceAlias).ConnectionSpecificSuffix
|
||||
SearchList = (Get-DnsClientGlobalSetting).SuffixSearchList
|
||||
SI04 = @([Net.Dns]::GetHostAddresses('SI-04') | ForEach-Object IPAddressToString)
|
||||
SGUDC02 = @([Net.Dns]::GetHostAddresses('SGU-DC02') | ForEach-Object IPAddressToString)
|
||||
}
|
||||
Reference in new issue
Block a user