Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Wednesday, October 9, 2019 8:59 PM | 1 vote
Hi all,
I am a longtime Linux user, and since WSL2 was released, I decided to switch my main work system from Ubuntu to Windows 10 to give it a spin. Most of my work has to be done in bash, so utilizing these Linux tools is vital to what I do.
For work, I utilize a VPN via OpenVPN. Because my VPN has a lower metric than other devices by default, DNS resolution by default utilized my local network rather than my company DNS. I looked up how to change the default metric on the interface, and managed to do so:
PS C:\Windows\system32> Get-NetIPInterface
ifIndex InterfaceAlias AddressFamily NlMtu(Bytes) InterfaceMetric Dhcp ConnectionState PolicyStore
51 Ethernet 3 IPv6 1500 25 Enabled Connected ActiveStore
47 Ethernet 2 IPv6 1500 25 Disabled Disconnected ActiveStore
39 vEthernet (Default Switch) IPv6 1500 15 Enabled Connected ActiveStore
9 Bluetooth Network Connection IPv6 1500 65 Disabled Disconnected ActiveStore
16 Local Area Connection* 10 IPv6 1500 25 Disabled Disconnected ActiveStore
2 Ethernet IPv6 1500 5 Disabled Disconnected ActiveStore
10 Wi-Fi IPv6 1500 35 Enabled Connected ActiveStore
1 Loopback Pseudo-Interface 1 IPv6 4294967295 75 Disabled Connected ActiveStore
51 Ethernet 3 IPv4 1500 1 Enabled Connected ActiveStore
47 Ethernet 2 IPv4 1500 25 Enabled Disconnected ActiveStore
39 vEthernet (Default Switch) IPv4 1500 5000 Disabled Connected ActiveStore
9 Bluetooth Network Connection IPv4 1500 65 Enabled Disconnected ActiveStore
16 Local Area Connection* 10 IPv4 1500 25 Enabled Disconnected ActiveStore
4 Local Area Connection* 1 IPv4 1500 25 Enabled Disconnected ActiveStore
2 Ethernet IPv4 1500 5 Enabled Disconnected ActiveStore
10 Wi-Fi IPv4 1500 35 Enabled Connected ActiveStore
1 Loopback Pseudo-Interface 1 IPv4 4294967295 75 Disabled Connected ActiveStore
PS C:\Windows\system32> Set-NetIPInterface -InterfaceIndex 51 -InterfaceMetric 1
PS C:\Windows\system32> Get-NetIPInterface -InterfaceIndex 51
ifIndex InterfaceAlias AddressFamily NlMtu(Bytes) InterfaceMetric Dhcp ConnectionState PolicyStore
51 Ethernet 3 IPv6 1500 1 Enabled Connected ActiveStore
51 Ethernet 3 IPv4 1500 1 Enabled Connected ActiveStore
Doing this allows me to resolve my DNS without issues using my company DNS:
PS C:\Windows\system32> Resolve-DnsName somehost.mycompany.com
Name Type TTL Section IPAddress
somehost.mycompany.com A 300 Answer 10.10.10.10
That being said, in Ubuntu using WSL, I still can't do resolutions:
robbc@saitama:~$ dig somehost.mycompany.com +nocomments +noquestion +noauthority +noadditional +nostats
; <<>> DiG 9.11.3-1ubuntu1.7-Ubuntu <<>> somehost.mycompany.com +nocomments +noquestion +noauthority +noadditional +nostats
;; global options: +cmd
If I directly specify the DNS server, because the tunnel has access to my company's network, it works just fine:
robbc@saitama:~$ dig @10.10.10.1 somehost.mycompany.com
; <<>> DiG 9.11.3-1ubuntu1.7-Ubuntu <<>> @10.10.10.1 somehost.mycompany.com
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 64990
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;somehost.mycompany.com. IN A
;; ANSWER SECTION:
somehost.mycompany.com. 87 IN A 10.10.10.10
;; Query time: 103 msec
;; SERVER: 10.11.5.19#53(10.11.5.19)
;; WHEN: Wed Oct 09 14:48:34 MDT 2019
;; MSG SIZE rcvd: 75
The default `/etc/resolv.conf` generated by WSL has my correctly identified DNS server in it, but it is in the third position, still not resolving:
robbc@saitama:~$ cat /etc/resolv.conf
# This file was automatically generated by WSL. To stop automatic generation of this file, remove this line.
nameserver 192.168.1.1
nameserver 10.5.0.1
nameserver 10.10.10.1
search mycompany.com
If I reverse the order of `/etc/resolv.conf` to put `10.10.10.1` up top, it works fine, but everytime I launch WSL I need to do this after I connect to the VPN - even if I connect to the VPN first, and then do WSL.
The same behavior in Linux doesn't cause an issue; each nameserver is evaluated in turn, but that doesn't seem to be the case in WSL, and I have no idea why. Am I doing something wrong perhaps? I know very, very little about Windows, this is my first forray into using it at all. I hesitate to remove the autogeneration line for when I am not on VPN, since I still want to resolve other times.
Thanks!
<style><br _moz_dirty="" /></style>
All replies (4)
Sunday, October 13, 2019 1:28 AM âś…Answered
I found out that this is a non-issue in WSL2; since WSL2 utilizes a NAT'd Virtual Machine, there is an internal DNS resolver it uses within the NAT that uses everything the Windows 10 host does, so resolution works perfectly now even with changing addresses.
Easy solution is to upgrade to Windows Subsystem for Linux 2 (Tech Preview, Insiders only currently).
<style></style>
Thursday, October 10, 2019 7:37 AM | 1 vote
Hi.
Thanks for your question.
This is a quick note to let you know that I am currently performing research on this issue and will get back to you as soon as possible. I appreciate your patience.
If you have any updates during this process, please feel free to let me know.
Best regards,
Michael
Please remember to mark the replies as an answers if they help.
If you have feedback for TechNet Subscriber Support, contact [email protected]
Sunday, October 13, 2019 1:29 AM
Upgrading to the tech preview of WSL2 resolved it for me; I wrote so down below. Thanks for your help!<style></style>
Monday, October 14, 2019 1:58 AM
Hi,
I'm very glad that your issue was resolved successfully! Highly appreciate your technical.
Thanks for your sharing and support.
Best regards,
Michael
Please remember to mark the replies as an answers if they help.
If you have feedback for TechNet Subscriber Support, contact [email protected]