Skip to content
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

Closed
gmatusko opened this issue Apr 28, 2016 · 7 comments · Fixed by #216
Closed

xDhcpClient doesn't set DNS servers back to DHCP #113

gmatusko opened this issue Apr 28, 2016 · 7 comments · Fixed by #216
Assignees
Labels
enhancement The issue is an enhancement request. in progress The issue is being actively worked on by someone.

Comments

@gmatusko
Copy link

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

@PlagueHO
Copy link
Member

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.

@PlagueHO
Copy link
Member

I'll revisit this one this weekend and see if I can't figure out a solution.

@kwirkykat kwirkykat added the enhancement The issue is an enhancement request. label Aug 2, 2016
@andy1547
Copy link

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.

@PlagueHO PlagueHO added help wanted The issue is up for grabs for anyone in the community. breaking change When used on an issue, the issue has been determined to be a breaking change. labels May 29, 2017
@PlagueHO
Copy link
Member

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:
In PowerShell there is no way to detect if the DNS Server Addresses assigned to an adapter were assigned as static or are DHCP assigned - so the DNS Client that was to be configured as being DHCP assigned will constantly be reported as not "in state" and will be continuously be reset to DHCP.

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 PlagueHO added discussion The issue is a discussion. and removed breaking change When used on an issue, the issue has been determined to be a breaking change. help wanted The issue is up for grabs for anyone in the community. labels May 29, 2017
@andy1547
Copy link

andy1547 commented May 29, 2017

@PlagueHO
I agree with you that it should be part of xDNSServerAddress not xDhcpClient.

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).
This registry key being null or empty holds the answer
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\\{Network_Adaptor_GUID}\NameServer

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.

  • If flag and the desired configuration of xDNSServerAddress IPs are empty, we have a match and we should not call set (DNS is already dynamically configured).
  • If flag and the configuration of xDNSServerAddress IPs are not empty, then the static IPs will be set.
  • if !flag (the IPs returned from the NIC are statically set) we simply return them and compare with what the desired configuration is.

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.
The TestResource would perform filtering before comparing the desired state (to only return the "REAL" DNS IPs).

@PlagueHO
Copy link
Member

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.

@PlagueHO PlagueHO added in progress The issue is being actively worked on by someone. and removed discussion The issue is a discussion. labels Jun 3, 2017
@PlagueHO
Copy link
Member

PlagueHO commented Jun 3, 2017

I'm working on this now and aim to have it completed by the end of today.

tysonjhayes pushed a commit that referenced this issue Jun 16, 2017
Add DHCP support to xDNSServerAddress - Fixes #113
@SteveL-MSFT SteveL-MSFT added this to In progress in powershell/dscresources May 14, 2019
@SteveL-MSFT SteveL-MSFT removed this from In progress in powershell/dscresources Nov 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement The issue is an enhancement request. in progress The issue is being actively worked on by someone.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants