Skip to main content
Background Image
  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

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.
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.
About
How to enable, configure and disable Jenkins LDAP
·183 words·1 min
This article explains how to enable and configure LDAP authentication in Jenkins, including how to disable it temporarily if needed.