ChrisTitusTech / winutil

Chris Titus Tech's Windows Utility - Install Programs, Tweaks, Fixes, and Updates

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DNS setting fails with error

totokpeter opened this issue · comments

Describe the bug
Tried setting Cloudflare as DNS provider

To Reproduce
Steps to reproduce the behavior:

  1. Go to 'Tweaks'
  2. Click on any alternative DNS provider other than 'Default'
  3. Click 'Run Tweaks'
  4. See error

Expected behavior
DNS set to other than 'DHCP' or 'Default'

Screenshots
image

Additional context

Ensuring DNS is set to Cloudflare on the following interfaces

Name                      InterfaceDescription                    ifIndex Status       MacAddress             LinkSpeed
----                      --------------------                    ------- ------       ----------             ---------
vEthernet (External VM... Hyper-V Virtual Ethernet Adapter #2          16 Up           58-11-22-B2-CC-80         1 Gbps
Ethernet                  Realtek Gaming 2.5GbE Family Controller       6 Up           58-11-22-B2-CC-80         1 Gbps



Set-DnsClientServerAddress : No MSFT_DNSClientServerAddress objects found with property 'InterfaceIndex' equal to '6'.
 Verify the value of the property and retry.
At line:2196 char:17
+ ...             Set-DnsClientServerAddress -InterfaceIndex $Adapter.ifInd ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (6:UInt32) [Set-DnsClientServerAddress], CimJobException
    + FullyQualifiedErrorId : CmdletizationQuery_NotFound_InterfaceIndex,Set-DnsClientServerAddress

Running Script for WPFTweaksRestorePoint
WARNING: The 'Microsoft.PowerShell.Management' module was not imported because the 'Microsoft.PowerShell.Management'
snap-in was already imported.
System Restore Point Created Successfully

The easiest solution here would be to pipe the Set-DnsClientServerAddress call with the Get-DnsClient function.

https://learn.microsoft.com/en-us/powershell/module/dnsclient/get-dnsclient?view=windowsserver2022-ps

The easiest solution here would be to pipe the Set-DnsClientServerAddress call with the Get-DnsClient function.

https://learn.microsoft.com/en-us/powershell/module/dnsclient/get-dnsclient?view=windowsserver2022-ps

Totally works, just doesn't set it for the physical interface which is strange.

PS C:\Users\totok> Get-DnsClient | Set-DnsClientServerAddress -ServerAddresses ("1.1.1.1","1.0.0.1")
PS C:\Users\totok> Get-DnsClientServerAddress

InterfaceAlias               Interface Address ServerAddresses
                             Index     Family
--------------               --------- ------- ---------------
vEthernet (External VM Sw...        16 IPv4    {1.1.1.1, 1.0.0.1}
vEthernet (External VM Sw...        16 IPv6    {}
Bluetooth Network Connection        11 IPv4    {1.1.1.1, 1.0.0.1}
Bluetooth Network Connection        11 IPv6    {}
Loopback Pseudo-Interface 1          1 IPv4    {1.1.1.1, 1.0.0.1}
Loopback Pseudo-Interface 1          1 IPv6    {}
vEthernet (Default Switch)          20 IPv4    {1.1.1.1, 1.0.0.1}
vEthernet (Default Switch)          20 IPv6    {}


PS C:\Users\totok> Get-DnsClient

InterfaceAlias               Interface ConnectionSpecificSuffix ConnectionSpecificSuffix RegisterThisConn UseSuffixWhen
                             Index                              SearchList               ectionsAddress   Registering
--------------               --------- ------------------------ ------------------------ ---------------- -------------
vEthernet (External VM Sw...        16                          {}                       True             False
Bluetooth Network Connection        11                          {}                       True             False
Loopback Pseudo-Interface 1          1                          {}                       True             False
vEthernet (Default Switch)          20                          {}                       False            False


PS C:\Users\totok> Get-NetAdapter -Name * -Physical

Name                      InterfaceDescription                    ifIndex Status       MacAddress             LinkSpeed
----                      --------------------                    ------- ------       ----------             ---------
Ethernet                  Realtek Gaming 2.5GbE Family Controller       6 Up           58-11-22-B2-CC-80         1 Gbps

That's odd, I gave it a spin before handing it out here.

I have a gut feeling that this has something to do with you having Hyper-V installed on your machine. If I remember correctly Hyper-V on Windows was a bit funny in terms of which NICs are shown as active and are actually used so that the Physical NIC was shown as enabled and active but didn't even have an IP assigned. Instead, Windows would route all the traffic through one of the virtual NICs even for the physical hypervisor itself. I have no access to any Hyper-V Systems at the moment and therefore cannot verify this to the end, but maybe this info helps to guide the debugging process

Closed due to inactivity