Skip to main content
  1. Posts/

How to fix "Temporary Failure in name resolution" in WSL

·176 words·1 min· ·
Xianpeng Shen
Author
Xianpeng Shen
Table of Contents

Problem
#

I have encountered a problem when I ping google.com failed and return some error like “Temporary failure in name resolution”

How to fix
#

  1. Inside WSL2, create or append file: /etc/wsl.conf

  2. Put the following lines in the file in order to ensure the your DNS changes do not get blown away

    sudo tee /etc/wsl.conf << EOF
    [network]
    generateResolvConf = false
    EOF
    
  3. In a cmd windows (!!), run wsl --shutdown

  4. Start WSL2

  5. Run the following inside WSL2 (line with search is optional)

sudo rm -rf /etc/resolv.conf
sudo tee /etc/resolv.conf << EOF
search yourbase.domain.local
nameserver 8.8.8.8
nameserver 1.1.1.1
EOF

In my case, I can remove /etc/resolv.conf and error is “rm: cannot remove ‘/etc/resolv.conf’: Operation not permitted”

# use following command instead fixed.
sudo chattr -a -i /etc/resolv.conf

Reference links#

https://askubuntu.com/questions/1192347/temporary-failure-in-name-resolution-on-wsl https://askubuntu.com/questions/125847/un-removable-etc-resolv-conf


转载本站文章请注明作者和出处,请勿用于任何商业用途。欢迎关注公众号「DevOps攻城狮」

Related

Developing on Windows Just Got Awesome using WSL + VS Code + Docker Desktop - Worth a Try
·731 words·2 mins
This article introduces how to develop on Windows using WSL, VS Code, and Docker Desktop. It provides detailed installation and configuration steps, as well as the advantages and experience of using these tools.
How to fix "hidden symbol `__gcov_init' in ../libgcov.a(_gcov.o) is referenced by DSO"
·323 words·2 mins
This article explains how to resolve the “hidden symbol `__gcov_init’ in ../libgcov.a(_gcov.o) is referenced by DSO” error when building a project with Gcov, including how to ensure symbols are not hidden.
Fixed "Remote session was disconnected because there are no Remote Desktop client access licenses available"
·152 words·1 min
Fix the RDP connection issue on Windows Server 2012 R2, where the error message indicates that there are no Remote Desktop client access licenses available.
Restrict others from login your important Linux machine
·182 words·1 min
This article explains how to restrict access to a critical Linux machine by modifying the /etc/security/access.conf file, allowing only specific users to log in.
C/C++ Code Formatting and Static Analysis—A One-Stop Workflow with Cpp Linter
·1281 words·7 mins
This article introduces tools and workflows for C/C++ code formatting and static analysis, focusing on the use and integration of clang-tools.
How to create GPG keys and add to GitHub
·370 words·1 min
This article explains how to create GPG keys, export the public key, and add it to GitHub for signing commits.