Closed gardart closed 3 years ago
$adDomain = Get-ADDomain $domain = $adDomain.DNSRoot $domainDn = $adDomain.DistinguishedName
$vagrantNatAdapter = Get-NetAdapter -Physical | Where-Object {$_ | Get-NetIPAddress | Where-Object {$_.PrefixOrigin -eq 'Dhcp'}} | Sort-Object -Property Name ` | Select-Object -First 1 $vagrantNatIpAddress = ($vagrantNatAdapter | Get-NetIPAddress).IPv4Address
| Where-Object {$_ | Get-NetIPAddress | Where-Object {$_.PrefixOrigin -eq 'Dhcp'}}
$vagrantNatAdapter | Set-DnsClient -RegisterThisConnectionsAddress $false Get-DnsServerResourceRecord -ZoneName $domain -Type 1 | Where-Object {$_.RecordData.IPv4Address -eq $vagrantNatIpAddress} | Remove-DnsServerResourceRecord -ZoneName $domain -Force
| Where-Object {$_.RecordData.IPv4Address -eq $vagrantNatIpAddress}
$vagrantNatAdapter | Disable-NetAdapterBinding -ComponentID ms_tcpip6
$dnsServerSettings = Get-DnsServerSetting -All $dnsServerSettings.ListeningIPAddress = @( $dnsServerSettings.ListeningIPAddress ` | Where-Object {$_ -ne $vagrantNatIpAddress} ) Set-DnsServerSetting $dnsServerSettings
Clear-DnsClientCache
fixed with powershell script
$adDomain = Get-ADDomain $domain = $adDomain.DNSRoot $domainDn = $adDomain.DistinguishedName
remove the non-routable vagrant nat ip address from dns.
NB this is needed to prevent the non-routable ip address from
being registered in the dns server.
NB the nat interface is the first dhcp interface of the machine.
$vagrantNatAdapter = Get-NetAdapter -Physical
| Where-Object {$_ | Get-NetIPAddress | Where-Object {$_.PrefixOrigin -eq 'Dhcp'}}
| Sort-Object -Property Name ` | Select-Object -First 1 $vagrantNatIpAddress = ($vagrantNatAdapter | Get-NetIPAddress).IPv4Addressremove the $domain nat ip address resource records from dns.
$vagrantNatAdapter | Set-DnsClient -RegisterThisConnectionsAddress $false Get-DnsServerResourceRecord -ZoneName $domain -Type 1
| Where-Object {$_.RecordData.IPv4Address -eq $vagrantNatIpAddress}
| Remove-DnsServerResourceRecord -ZoneName $domain -Forcedisable ipv6.
$vagrantNatAdapter | Disable-NetAdapterBinding -ComponentID ms_tcpip6
remove the dc.$domain nat ip address resource record from dns.
$dnsServerSettings = Get-DnsServerSetting -All $dnsServerSettings.ListeningIPAddress = @( $dnsServerSettings.ListeningIPAddress ` | Where-Object {$_ -ne $vagrantNatIpAddress} ) Set-DnsServerSetting $dnsServerSettings
flush the dns client cache.
Clear-DnsClientCache