gardart / ansible-freeipa-lab

Testing environment for FreeIPA identity management (IDM) with Active Directory
MIT License
7 stars 1 forks source link

Fix DNS listening on NAT ip #4

Closed gardart closed 3 years ago

gardart commented 3 years ago

$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).IPv4Address

remove 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 -Force

disable 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

gardart commented 3 years ago

fixed with powershell script