Last active
February 27, 2025 10:21
Revisions
-
djfdyuruiry revised this gist
May 28, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -35,4 +35,4 @@ This guide will help overcome the DNS issues present in WSL 2 while still making # it for XServer setup etc. ``` - Exit and then go back into your WSL terminal -
djfdyuruiry revised this gist
May 28, 2020 . 1 changed file with 0 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -22,12 +22,6 @@ This guide will help overcome the DNS issues present in WSL 2 while still making %admin ALL = (root) NOPASSWD: /opt/configure-wsl-dns.sh ``` - Update `~/.zshrc` or `~/.bashrc`: ```bash -
djfdyuruiry revised this gist
May 28, 2020 . 1 changed file with 4 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,7 @@ # Fix DNS Issues in WSL 2 This guide will help overcome the DNS issues present in WSL 2 while still making the Windows host IP autogenerated by WSL available for use. Note: this was tested on Windows 10 Build 2004, running Ubuntu 20.04 LTS in WSL 2. - Open a WSL terminal - Copy the contents of `configure-wsl-dns.sh` to `/opt/configure-wsl-dns.sh`: @@ -38,5 +42,3 @@ ``` - Exit and then go back into WSL terminal -
djfdyuruiry revised this gist
May 28, 2020 . 1 changed file with 4 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -31,6 +31,10 @@ sudo /opt/configure-wsl-dns.sh export $(</etc/wsl-host.env) # The env var 'WSL_HOST' is now available which # contains the IP of the host machine if you need # it for XServer setup etc. ``` - Exit and then go back into WSL terminal -
djfdyuruiry revised this gist
May 28, 2020 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -34,3 +34,5 @@ ``` - Exit and then go back into WSL terminal *Tested on Ubuntu 20.04 LTS and Windows 10 2004* -
djfdyuruiry created this gist
May 28, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,36 @@ - Open a WSL terminal - Copy the contents of `configure-wsl-dns.sh` to `/opt/configure-wsl-dns.sh`: ```bash sudo nano /opt/configure-wsl-dns.sh ``` - Make it executable: ```bash sudo chmod +x /opt/configure-wsl-dns.sh ``` - Add a passwordless sudo entry in the file `/etc/sudoers.d/configure-wsl-dns`: ``` %admin ALL = (root) NOPASSWD: /opt/configure-wsl-dns.sh ``` - Fix an issue with `dbus`: ```bash sudo sh -c "dbus-uuidgen > /etc/machine-id" ``` - Update `~/.zshrc` or `~/.bashrc`: ```bash # WSL networking sudo /opt/configure-wsl-dns.sh export $(</etc/wsl-host.env) ``` - Exit and then go back into WSL terminal This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,45 @@ #! /usr/bin/env bash set -e resolvConfPath="/etc/resolv.conf" resolvConfDirPath="/etc/resolvconf/resolv.conf.d" resolvHeadConfPath="${resolvConfDirPath}/head" wslHostEnvPath="/etc/wsl-host.env" function writeResolvConf() { cat > "$1" <<- EOM ## Change the below as you see fit # cloudflare nameserver 1.1.1.1 # google nameserver 8.8.8.8 # local nameserver 192.168.0.1 EOM } function saveWslHostConfig() { rm -f "${wslHostEnvPath}" local wslHost=$(cat "${resolvConfPath}" | grep -v '#' | cut -d ' ' -f 2) printf "WSL_HOST=${wslHost}" > "${wslHostEnvPath}" } function main() { # exit if resolv.conf has already been patched grep 'generated by WSL' /etc/resolv.conf > /dev/null || exit 0 saveWslHostConfig writeResolvConf "${resolvConfPath}" # if systemd is enabled - you will need this mkdir -p "${resolvConfDirPath}" writeResolvConf "${resolvHeadConfPath}" } main