Main Menu
  • COMPANY
    • Boundless Cybersecurity
    • Press Releases
    • News
    • Events
    • Awards
    • Leadership
    • Press Kit
    • Careers
  • PROMOTIONS
    • SonicWall Promotions
    • Customer Loyalty Program
  • MANAGED SERVICES
    • Managed Security Services
    • Security as a Service
    • Professional Services
SonicWall
  • Products
      All Products A–Z
      Free Trials
    • Network Security
      • Next-Generation Firewall (NGFW)
      • Network Security Services
      • Network Security Management
      • Secure SD-WAN
    • Threat Protection
      • Advanced Threat Protection Cloud
      • Advanced Threat Protection Appliance
      • Capture Labs
    • Secure Access Service Edge (SASE)
      • Zero-Trust Network Access (ZTNA)
    • Cloud Security
      • Cloud Firewall
      • Cloud App Security
    • Endpoint Security
      • Endpoint Detection & Response (EDR)
    • Email Security
      • Cloud Email Security
      • Hosted Email Security
      • On-Prem Email Security
    • Secure Access
      • Wireless Access Points
      • Network Switch
      • Virtual Private Network (VPN)
    • Wi-Fi 6 Access Points

      SonicWall SonicWave 600 series access points provide always-on, always-secure connectivity for complex, multi-device environments.

      Read More
  • Solutions
    • Industries
      • Distributed Enterprises
      • Retail & Hospitality
      • K-12 Education
      • Higher Education
      • State & Local
      • Federal
      • Healthcare
      • Financial Services
      • Carriers
    • Use Cases
      • Secure SD-Branch
      • Network Segmentation
      • Zero Trust Security
      • Secure SD-WAN
      • Office 365 Security
      • SaaS Security
      • Secure Wi-Fi
    • Solutions Widgets
      • Solutions Content Widgets
        Federal

        Protect Federal Agencies and Networks with scalable, purpose-built cybersecurity solutions

      • Solutions Image Widgets
  • Partners
    • SonicWall Partners
      • Partners Overview
      • Find a Partner
      • Authorized Distributors
      • Technology Partners
    • Partner Resources
      • Become a Partner
      • SonicWall University
      • Training & Certification
    • Partner Widgets
      • Custom HTML : Partners Content WIdgets
        Partner Portal

        Access to deal registration, MDF, sales and marketing tools, training and more

      • Partners Image Widgets
  • Support
    • Support
      • Support Portal
      • Knowledge Base
      • Technical Documentation
      • Community
      • Video Tutorials
      • Product Life Cycle Tables
      • Partner Enabled Services
      • Contact Support
    • Resources
      • Resource Center
      • Events
      • Free Trials
      • Blog
      • SonicWall University
      • MySonicWall
    • Capture Labs
      • Capture Labs
      • Security Center
      • Security News
      • PSIRT
      • Application Catalog
    • Support Widget
      • Custom HTML : Support Content WIdgets
        Support Portal

        Find answers to your questions by searching across our knowledge base, community, technical documentation and video tutorials

      • Support Image Widgets
  • COMPANY
    • Boundless Cybersecurity
    • Press Releases
    • News
    • Events
    • Awards
    • Leadership
    • Press Kit
    • Careers
  • PROMOTIONS
    • SonicWall Promotions
    • Customer Loyalty Program
  • MANAGED SERVICES
    • Managed Security Services
    • Security as a Service
    • Professional Services
  • Contact Sales
  • English English English en
  • BLOG
  • CONTACT SALES
  • FREE TRIALS
  • English English English en
SonicWall
  • Products
      All Products A–Z
      Free Trials
    • Network Security
      • Next-Generation Firewall (NGFW)
      • Network Security Services
      • Network Security Management
      • Secure SD-WAN
    • Threat Protection
      • Advanced Threat Protection Cloud
      • Advanced Threat Protection Appliance
      • Capture Labs
    • Secure Access Service Edge (SASE)
      • Zero-Trust Network Access (ZTNA)
    • Cloud Security
      • Cloud Firewall
      • Cloud App Security
    • Endpoint Security
      • Endpoint Detection & Response (EDR)
    • Email Security
      • Cloud Email Security
      • Hosted Email Security
      • On-Prem Email Security
    • Secure Access
      • Wireless Access Points
      • Network Switch
      • Virtual Private Network (VPN)
    • Wi-Fi 6 Access Points

      SonicWall SonicWave 600 series access points provide always-on, always-secure connectivity for complex, multi-device environments.

      Read More
  • Solutions
    • Industries
      • Distributed Enterprises
      • Retail & Hospitality
      • K-12 Education
      • Higher Education
      • State & Local
      • Federal
      • Healthcare
      • Financial Services
      • Carriers
    • Use Cases
      • Secure SD-Branch
      • Network Segmentation
      • Zero Trust Security
      • Secure SD-WAN
      • Office 365 Security
      • SaaS Security
      • Secure Wi-Fi
    • Solutions Widgets
      • Solutions Content Widgets
        Federal

        Protect Federal Agencies and Networks with scalable, purpose-built cybersecurity solutions

      • Solutions Image Widgets
  • Partners
    • SonicWall Partners
      • Partners Overview
      • Find a Partner
      • Authorized Distributors
      • Technology Partners
    • Partner Resources
      • Become a Partner
      • SonicWall University
      • Training & Certification
    • Partner Widgets
      • Custom HTML : Partners Content WIdgets
        Partner Portal

        Access to deal registration, MDF, sales and marketing tools, training and more

      • Partners Image Widgets
  • Support
    • Support
      • Support Portal
      • Knowledge Base
      • Technical Documentation
      • Community
      • Video Tutorials
      • Product Life Cycle Tables
      • Partner Enabled Services
      • Contact Support
    • Resources
      • Resource Center
      • Events
      • Free Trials
      • Blog
      • SonicWall University
      • MySonicWall
    • Capture Labs
      • Capture Labs
      • Security Center
      • Security News
      • PSIRT
      • Application Catalog
    • Support Widget
      • Custom HTML : Support Content WIdgets
        Support Portal

        Find answers to your questions by searching across our knowledge base, community, technical documentation and video tutorials

      • Support Image Widgets
  • COMPANY
    • Boundless Cybersecurity
    • Press Releases
    • News
    • Events
    • Awards
    • Leadership
    • Press Kit
    • Careers
  • PROMOTIONS
    • SonicWall Promotions
    • Customer Loyalty Program
  • MANAGED SERVICES
    • Managed Security Services
    • Security as a Service
    • Professional Services
  • Contact Sales
  • Menu

Windows Subsystem for Linux (WSL) fails to use DNS from a VPN tunnel

12/17/2020 18 People found this article helpful 208,257 Views

    Download
    Print
    Share
    • LinkedIn
    • Twitter
    • Facebook
    • Email
    • Copy URL The link has been copied to clipboard

    Description

    Windows Subsystem for Linux (WSL) has a known problem with VPN based DNS.  See:

    https://github.com/Microsoft/WSL/issues/1350

     

    It appears the WSL BASH shell does not autogenerate the /etc/resolv.conf file correctly, or regenerate it when needed.   

    The result is that DNS updates provided to the Windows OS, by the establishment of a VPN tunnel, are not recognized in the WSL environment.  

    This is seen whether the WSL environment is brought up before or after the VPN tunnel is established.  

    Cause

    https://github.com/Microsoft/WSL/issues/1350

    Resolution

    Use the following shell script to clear this issue.  This script should only have to be run once on a particular instance of WSL. 

    Note: If the 'ed' command is not found, you will need to install it manually (Ex: sudo apt-get install ed).


    #!/bin/bash
    
    # Refer to https://github.com/Microsoft/WSL/issues/1350 for more information.
    # If the 'ed' command is not found, install it manually. (Ex: 'sudo apt-get install ed')
    
    # Instructions:
    # 1. Connect to the VPN.
    # 2. Run this script right admin rights from the WSL prompt.
    # 3. Test nslookup from the WSL prompt if the script runs successfully.
    
    echo "Modifying namesever for VPN"
    vpn() {
    [ -s /run/resolvconf/resolv.conf -a -L /etc/resolv.conf ] && sudo cp --remove-destination /run/resolvconf/resolv.conf /etc/resolv.conf
    local sudo="sudo"
    if [ -w /etc/resolv.conf ]; then sudo=""; fi
    $sudo ed -s /etc/resolv.conf <<'EOF'
    H
    a
    #EOF
    .
    kx
    g/^nameserver /d
    .-1r !/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe -Command '$x = Get-NetAdapter | Group-Object -AsHashtable -Property ifIndex; Get-DnsClientServerAddress -AddressFamily ipv4 | where {$x[$_.InterfaceIndex].Status -eq "Up"} | Select-Object -ExpandProperty ServerAddresses | foreach {"nameserver " + $_}' | sed 's/\r//g'
    'xd
    wq
    EOF
    }
    vpn
    echo "Done!"
    sleep 5


    The script may not work properly when pasted into a text editor. If you experience problems with the script, please try the base64-encoded string below.

    1. Copy the entire Base64 block and paste it into a blank text editor.
    2. Save the text file locally as vpn_script.txt.
    3. On the WSL prompt, change directory to where vpn_script.txt was saved. Enter the command: 'base64 -d vpn_script.txt >> vpn_script.sh'.
    4. The new file (vpn_script.sh) should contain the script text shown above and should avoid any issues with broken syntax due to new lines, etc.


    IyEvYmluL2Jhc2gKCiMgVGhpcyBzY3JpcHQgZml4ZXMgL2V0Yy9yZXNvbHYuY29uZiB0byBhZGRyZXNzIGFuIGlzc3VlIHdoZXJlIEROUyBpcyBub3QgdXBkYXRlZCBpbiBXU0wuCiMgUmVmZXIgdG8gaHR0cHM6Ly9naXRodWIuY29tL01pY3Jvc29mdC9XU0wvaXNzdWVzLzEzNTAgZm9yIG1vcmUgaW5mb3JtYXRpb24uCiMgSWYgdGhlICdlZCcgY29tbWFuZ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SB8IFNlbGVjdC1PYmplY3QgLUV4cGFuZFByb3BlcnR5IFNlcnZlckFkZHJlc3NlcyB8IGZvcmVhY2ggeyJuYW1lc2VydmVyICIgKyAkX30nIHwgc2VkICdzL1xyLy9nJwoneGQKd3EKRU9GCn0KdnBuCmVjaG8gIkRvbmUhIgpzbGVlcCA1

    Related Articles

    • How to deploy SMA100 series virtual appliance (SMA 500v) from one platform to another.
    • SMA100:After upgrading to 10.2.1.7, began receiving nonstop alert emails stating "WAF threat prevented:
    • SMA1000:When both IPv4 and IPv6 are enabled for the network interface, the first few connection attempts fail, but everything works fine after that.

    Categories

    • Secure Mobile Access > Mobile Connect
    • Secure Mobile Access > SMA 100 Series
    • Secure Mobile Access > SMA 1000 Series

    Not Finding Your Answers?

    ASK THE COMMUNITY

    Was This Article Helpful?

    YESNO

    Article Helpful Form

    Article Not Helpful Form

    Company
    • Careers
    • News
    • Leadership
    • Awards
    • Press Kit
    • Contact Us
    Popular resources
    • Communities
    • Blog
    • SonicWall Capture Labs

    Stay In Touch

    • By submitting this form, you agree to our Terms of Use and acknowledge our Privacy Statement. You can unsubscribe at any time from the Preference Center.
    • This field is for validation purposes and should be left unchanged.
    • Facebook
    • Twitter
    • Linkedin
    • Youtube
    • Instagram

    © 2023 SonicWall. All Rights Reserved.

    • Legal
    • Privacy
    • English
    Scroll to top