-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
xDhcpClient doesn't set DNS servers back to DHCP #113
Comments
Hi @gmatusko A great point (and needed feature). It would actually need to be implemented in the xDNSServerAddress resource because to reset the DNS Client back to using DHCP settings you actually issue: Set-DnsClientServerAddress -ResetServerAddresses -InterfaceAlias Ethernet If we added this in DHCP client then there would be a risk of a config that was conterminously reapplied. At first I thought this would be relatively easy, but it isn't quite so straight forward. One way of doing this would be to allow the Address property to accept a $null value. If $null is set then the Resource should ensure that the DNS client is set to DHCP mode. However, I can't find a way of identifying if the DNS client is currently set to DHCP mode or not. I'll need to do some more digging about on this. |
I'll revisit this one this weekend and see if I can't figure out a solution. |
In this case of switching from static to DHCP it should only reset back to automatic if no primary/secondary DNS is supplied, as it's possible to use both DHCP and a manual DNS server address. |
Thanks @andy1547 ! As I mentioned a while back, the solution wouldn't be to change xDHCPClient, but to change xDNSServerAddress so that it allowed a blank list of addresses - which would cause Set-DnsClientServerAddress -ResetServerAddresses -InterfaceAlias Ethernet to be called when the DNS client server addresses need to be changed back to DHCP. However there is one very major problem: For example, if you run: Get-DnsClientServerAddress -AddressFamily IPv4 | fl * you will see the information about the DNS Client server addresses - but you are not able to tell if the addresses in the ServerAddresses property are assigned via DHCP or not. So we can't tell if the resource is in state or not - which will result in continuously resetting the DNS Server Addresses - which will likely cause connectivity issues every time the config is applied. So I think the only solution is to be able to figure out if the DNS Server Addresses are set with DHCP or not - which will require some changes to PowerShell Net Client. Does that make sense? |
@PlagueHO The scenario you described happens both when the DNS is automatic or manual yet blank (sometimes mine would be 192.168.1.1, other times blank). When null or empty this flag would indicate that the DNS addresses returned may potentially be dynamically generated, therefore instead of returning them to be compared (which is pointless) you can return an empty list of IPs.
Moreover, the decision in the SetResource to call either reset or set static should be based on whether the desired configuration DNS IP array is empty or not. |
Hi @andy1547 - that is some great info. I would definitely prefer to use native cmdlets rather than the registry for this, but in the absence of the cmdlets I should be able to make your suggestion work. The plan would definitely to try and only make changes to xDNSServerAddress resource as that would be the safest solution. Let me see what I can do. |
I'm working on this now and aim to have it completed by the end of today. |
Add DHCP support to xDNSServerAddress - Fixes #113
It would be great if xDhcpClient checked if DNS settings for an adapter were set to "Obtain DNS server address automatically". Right now it only checks for IP settings and I'd like to switch DNS settings back to DCHP as well. Let me know if this is a reasonable request.
Greg
The text was updated successfully, but these errors were encountered: