Windows 10 connected to VPN: DNS issue and solution

We use OpenVPN to connect to some resources in AWS private subnets.
It works as expected on macOS, iOS, and even on old Windows 7, but not on Windows 10.
In case of Windows 10 when you’re connected to VPN (doesn’t matter OpenVPN, L2TP or even PPTP) you will still get responses from DNS server which is set on your Ethernet (or WiFi) adapter.

block-outside-dns option for OpenVPN didn’t fix this problem and I decided to provide solution for all VPN types, so here it is:

[pastacode lang=”bash” path_id=”2c8a6072720a1384bdff7dd27dd720e5″ file=”set-VpnAdapterMetric.ps1″ highlight=”” lines=”” provider=”gist”/]

You only have to fulfill variables mainIfName and vpnIfDescription with values relevant to your Windows installation:

I hope this info will be useful for you, and if you need any help feel free to use contact formĀ on the main page.