WSL: VPN still problematic

Background

Why does networking not work when connected to VPN when VPN /etc/resolv.conf entries are lower, but works (connected to VPN or not) when VPN entries appear before non-VPN entries? Contrary to what appears to be indicated here and here, I must still follow the advice here to manually edit /etc/resolv.conf to move the VPN entries to the top, then all works well. It seems that it tries all the entries when VPN is first (non-VPN DNS is utilized, after a brief pause, when disconnected from DNS with edited resolv.conf.)

Windows build number

  • Microsoft Windows [Version 10.0.15063]

What is happening

  • What you’re doing and what’s happening:
  1. Updated Windows to Creator
  2. Upgraded Cisco VPN Client (“Cisco AnyConnect Secure Mobility Client”) to version 4.4.02039
  3. Upgraded WSL when disconnected from VPN, successfully… $ lsb_release -d Description: Ubuntu 16.04.2 LTS
  4. Check /etc/resolv.conf
$ cat /etc/resolv.conf                                                                            
# This file was automatically generated by WSL. To stop automatic generation of this file, remove this line.
nameserver 84.200.69.80 # Home DNS1
nameserver 8.8.8.8  # Home DNS2
nameserver fec0:0:0:ffff::1
search Home
  1. Close Bash
  2. Connect to VPN in Windows (ensure it is working)
  3. Check /etc/resolv.conf again
$ cat /etc/resolv.conf
# This file was automatically generated by WSL. To stop automatic generation of this file, remove this line.
nameserver 84.200.69.80 # Same
nameserver 8.8.8.8 # Same
nameserver X.X.X.X # VPN DNS1
search Home americas.company.pvt # VPN FQDN
  1. Open Bash and try networking, and it fails…
$ ping google.com
ping: unknown host google.com

What works

  • What’s wrong / what should be happening instead:
  1. Disconnect VPN
  2. Reopen Bash
  3. Try again, works without issue
$ ping google.com
PING google.com (108.177.96.102) 56(84) bytes of data.
64 bytes from eh-in-f102.1e100.net (108.177.96.102): icmp_seq=1 ttl=42 time=170 ms
64 bytes from eh-in-f102.1e100.net (108.177.96.102): icmp_seq=2 ttl=42 time=163 ms
^C
--- google.com ping statistics ---
3 packets transmitted, 2 received, 33% packet loss, time 2000ms
rtt min/avg/max/mdev = 163.385/167.009/170.634/3.647 ms
  1. Alternatively, edit /etc/resolv.conf $ sudo nano /etc/resolv.conf
  2. Remove auto-gen comment line and move VPN entries to top (should the system not continue to work its way down if upper entries fail?)
$ cat /etc/resolv.conf
nameserver X.X.X.X	# VPN DNS1
nameserver X.X.X.X	# VPN DNS2
search Home americas.company.pvt # VPN FQDN
nameserver 84.200.69.80 # Home DNS1
nameserver 8.8.8.8 # Home DNS2

Straces

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Reactions: 1
  • Comments: 43 (5 by maintainers)

Most upvoted comments

If anyone’s interested, I was struggling with this issue for a while and was able to find a solution.

I’m connected to multiple vpns, each has it’s own dns server and manages different domains. This means that everytime I had to connect to hosts in diffrenet vpns I had to changes /etc/resolv.conf, since name resolution in linux will not try another nameserver (in resolv.conf) if the first nameserver returned an NXDOMAIN (i.e. non-existent domain).

Here’s my solution:

  1. Download and install Deadwood DNS for windows (http://maradns.samiam.org/deadwood/)
  2. Install it and configure the following (the rest I kept default):
upstream_servers = {}
upstream_servers["foo.io."]="<dns1 ip>"
upstream_servers["bar.int."]="<dns2 ip>"
upstream_servers["."]="8.8.8.8, 8.8.4.4" # Servers we connect to
recursive_acl = "0.0.0.0/0"
filter_rfc1918 = 0

Replace the domains (foo.io, bar.int) with your requirements (or add more if needed) and set the dns IP that will resolve each.

Note: I had to manually Disable and Stop the Internet Connection Sharing (ICS) service as it is binding to port 53.

  1. Restart deadwood service
  2. Configure this in your wsl /etc/resolv.conf
nameserver 127.0.0.1
search <list-of-your-domains>

enjoy 😄

I realize this is a bit of blog post… but figured anyone who’ll stumble upon this may enjoy this hack.

This is what I get in the log:

June 26, 2018 20:32:10 PM: Got DNS query for \006google\003com\000\000\001
Tuesday, June 26, 2018 20:32:10 PM: Looking in cache for query \006google\003com\000\000\001
Tuesday, June 26, 2018 20:32:10 PM: Nothing found for \006google\003com\000\000\001
Tuesday, June 26, 2018 20:32:10 PM: Caching direct answer at \006google\003com\000\000\001
Tuesday, June 26, 2018 20:32:10 PM: Looking in cache for query \006google\003com\000\000\001
Tuesday, June 26, 2018 20:32:10 PM: Fetching \006google\003com\000\000\001 from cache
Tuesday, June 26, 2018 20:32:10 PM: Got DNS query for \006google\003com\000\000\034
Tuesday, June 26, 2018 20:32:10 PM: Looking in cache for query \006google\003com\000\000\034
Tuesday, June 26, 2018 20:32:10 PM: Nothing found for \006google\003com\000\000\034
Tuesday, June 26, 2018 20:32:10 PM: Caching direct answer at \006google\003com\000\000\034
Tuesday, June 26, 2018 20:32:10 PM: Looking in cache for query \006google\003com\000\000\034
Tuesday, June 26, 2018 20:32:10 PM: Fetching \006google\003com\000\000\034 from cache

When I run netstat -anp | find ":53" in the command window whether Deadwood is running or not, I get nothing returned. That leads me to believe no service is using port 53. I tried using TCPView (https://docs.microsoft.com/en-us/sysinternals/downloads/tcpview) and did not see port 53 showing up anywhere. I tried all this with and without my Cisco AnyConnect VPN running.

For my site, Deadwood + Cisco AnyConnect VPN + WSL works well.

I also have the same problem as above, can’t get Deadwood to work for me.