Get-NetIpInterface VS "netsh interface ipv4 show interfaces"... different results on same interfaces -> changed metric not working on always on vpn interface

Dimitri Goossens 21 Reputation points
2021-04-22T05:54:39.287+00:00

Hi,

We're performing an Always On VPN project, and have an issue with DNS resolution.
In general we want the AOVPN interface to have a lower metric then the wired NIC.
THe DNS gets chosen, based on the interface with the lowest metric.

We're using a script from Richard Hicks to change the metric of the AOVPN interface.
(https://github.com/richardhicks/aovpn/blob/master/Update-Rasphone.ps1)
It does get set correctly, and is being changed in the rasphone.pbk file located in : "C:\ProgramData\Microsoft\Network\Connections\"
(we're installing it for all users, hence the location of the file).

So far, so good.. Everything seems to get adapted correctly (verified metric on GUI interface too, and it shows the changed metric).

However when a client connects via VPN, they still get the ISP DNS server (via wired interface) to respond instead of the internal DNS server.
Lowering the metric of the AOVPN interface, should have forced this DNS to be used.

Now for the question :)

When checking the metric of the connections via "netsh interface ipv4 show interfaces", the metric is correct (we see the changed one)

When checking via Get-NetIPInterface, the old value is still shown, valued 25, which is automatic. This is the metric being used, and the one queried with netsh is being ignored.

Does anyone know why there is a difference in both ways to query them?

Windows for business Windows Client for IT Pros Networking Network connectivity and file sharing
0 comments No comments
{count} votes

7 answers

Sort by: Most helpful
  1. Anonymous
    2021-04-27T08:33:10.333+00:00

    Now , we can narrow down the issue is related with scripts. Don't use script to change the metric. As far as I know, when you connect to VPN successfully, VPN 's adapter interface metric will auto lower than other interface.

    Make sure adapters' interface metric are setting to Automatic metric. Then do not use script to change the metric, connect to VPN and then check the results.

    0 comments No comments

  2. Dimitri Goossens 21 Reputation points
    2021-04-27T08:39:12.753+00:00

    The wired interface will always have priority (lower metric) then the AOVPN interface by default.
    The AOVPN adapter has the same metric as a wireless interface by default, which is 25.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.